Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony2 twig and multiple levels of subfolders

Tags:

php

twig

symfony

I find that including a template with this path works fine

{% include 'AcmeDemoBundle:TemplateArchive:view.html.twig' with {'data': c.data} %}

While this is seemingly not allowed:

{% include 'AcmeDemoBundle:TemplateArchive:6:view.html.twig' with {'data': c.data} %}

I am in other words trying to reach templates that I have sorted down into a subfolder structure in my bundle/resources/views/ folder.

If I am not allowed to drill any deeper than the regular one-level-inclusion as of my first line, is there another/better way of structuring these template files?

(the folder name '6' represents a template id from the database which I would like to include, it needs to be dynamic and sorted in folders nicely like that...).

I have tried naming my templates-folder 't6' but no difference, the "number with no leading letters" is not the issue here...

like image 886
Matt Welander Avatar asked Oct 12 '12 08:10

Matt Welander


2 Answers

What about

{% include 'AcmeDemoBundle:TemplateArchive:6/view.html.twig' with {'data': c.data} %}
like image 50
PatrikAkerstrand Avatar answered Oct 13 '22 19:10

PatrikAkerstrand


Both is working:

AcmeDemoBundle:TemplateArchive:6/view.html.twig
AcmeDemoBundle:TemplateArchive/6:view.html.twig
like image 6
bench-o Avatar answered Oct 13 '22 18:10

bench-o