在模板中,我使用的是include
就像这样:
{% include "blah.html" with x="..." only %}
我可以用x
在blh.html中。
现在我希望blh.html将默认值设置为x
如果它不是由“父”模板传递的。:
{% include "blah.html" only %}
由于显然没有内置模板标记来在模板中设置变量,我不知道这是如何实现的.
发布于 2018-08-06 15:09:05
你试过在“blh.html”中使用:
{% with x=x|default:"nothing" %} <!-- first line after load tags -->
<!-- ^^^^ -->
<!-- YOUR CODE HERE -->
{% endwith %}<!-- last line -->
https://stackoverflow.com/questions/-100005913
复制相似问题