include - Jinja 使用变量作为 Jinja “包含”中使用的文件的名称
问题描述
在 jinja 中,我试图将变量传递到“include”使用的文件名中,例如:{% include = variable1 %}
像这样的东西:
{% set filepath = ['Templates/file1.j2', 'Templates/file2.j2', 'Templetes/file3.j2'] %}
These are the files:
{% for list in filepath -%}
'{{ list }}'
{% endfor %}
{% set Mypath = filepath[1] %}
This is the path and file to use: '{{ Mypath }}'
{% include "'" Mypath "'" %}
我希望达到的结果应该是这样的。
{% include = 'Templates/file2.j2' %}.
是否可以在 Jinja 中以这种方式将变量传递给包含?
解决方案
推荐阅读
- typo3 - TYPO3 9.5 需要教程
- vb.net - VB超参考
- spfx - @pnp/sp 似乎缺少 .get() 方法
- c# - 当连接状态关闭时,Ora-24309 怎么会发生?
- laravel - 优化 ApiResource
- javascript - ReactJS 操作从 SQLITE3 数据库中提取的对象数据
- jenkins - Nuget 恢复不适用于 Jenkins 上的 Xamarin 表单
- html - 在一个选择中使用 :nth-child 和 :nth-last-child
- java - EntityManager 没有名为 defaultPersistenceUnit 的持久性提供程序,不会创建 EntityManagerFactory
- css - 悬停时如何为元素设置相同的颜色?