We know, {% include header.volt %}
is reference file with name's header.volt
.
How can I dynamically reference template file in volt template?
like this:
{% include variable %}
when variable equal footer.volt
, theen the program will reference file with name's footer.volt
when variable equal index.volt
, then the program will reference file with name's index.volt
...
thanks!
I'm not sure if using variables in include will work, but you can always use partial()
to include your template:
{% set partialName = 'footer' %}
{{ partial('partials/'~partialName) }}