Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template Partials in Symfony 2

Are there such things as partials in Symfony 2, reusable templates from anywhere, effectively?

I have found include http://twig.sensiolabs.org/doc/tags/include.html but this only allows the rendering of a template in a specific directory structure.

What I really want a folder that contains all my partial templates, rather than lumping them into my main views?

So I want to be able to do something like

{% include "Bundle:Default:Partials:view.html.twig" %}

Update

I do not want to use the enforced structure of Bundle:Controller:Template structure. I do not want to use this as it means putting all my template partials in with my main view templates. I need something that lets me do Bundle:Controller:PartialDir:Template

like image 365
Jake N Avatar asked Dec 16 '22 15:12

Jake N


1 Answers

You can already do that. The symfony2 docs has a section describing how to do this.

http://symfony.com/doc/current/book/templating.html#including-other-templates

like image 85
dteoh Avatar answered Dec 28 '22 07:12

dteoh