Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an include_partial equivalent in Twig (symfony 2.0)?

Tags:

twig

symfony

I really like to use partial templates in my symfony 1.4 projets and I was wondering if there is something like that with Twig in symfony 2.0.

It's way more clear and reusable to have something like that

<?php include_partial('forum/message', array('message'=>$message)); ?> 

Rathen than a big portion of php/html code.

like image 696
Julien G Avatar asked Dec 06 '11 20:12

Julien G


People also ask

What is Twig in Symfony?

Twig is a template engine for the PHP programming language. Its syntax originates from Jinja and Django templates. It's an open source product licensed under a BSD License and maintained by Fabien Potencier. The initial version was created by Armin Ronacher.

What is block in twig?

Blocks are used for inheritance and act as placeholders and replacements at the same time. They are documented in detail in the documentation for the extends tag. Block names must consist of alphanumeric characters, and underscores. The first char can't be a digit and dashes are not permitted.

What is a twig extension?

Twig Extensions allow the creation of custom functions, filters, and more to use in your Twig templates.


1 Answers

Yes. It's called include in Twig. Details are in the docs.

like image 163
Elnur Abdurrakhimov Avatar answered Oct 11 '22 21:10

Elnur Abdurrakhimov