Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们知道,{% include header.volt %}是名称为header.volt. 如何在 volt 模板中动态引用模板文件? 像这样: {% include variable %} 当变量相等时footer.volt,程序将引用文件名footer.volt 当变量相等时index.volt,程序将引用文件名index.volt...
{% include header.volt %}
header.volt
{% include variable %}
footer.volt
index.volt
谢谢!
我不确定在 include 中使用变量是否有效,但您始终可以使用partial()来包含您的模板:
partial()
{% set partialName = 'footer' %} {{ partial('partials/'~partialName) }}