问题
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!
回答1:
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) }}
来源:https://stackoverflow.com/questions/19827002/how-can-i-dynamically-reference-template-file-in-volt-template