我希望根据代码中的条件将值传递给变量.以下是我试图实现的伪代码:
{% include "includes/template.html" with info=if condition: a else: b %}
我在想我怎么才能做到这一点.如有任何建议或指导,我们将不胜感激!
我希望根据代码中的条件将值传递给变量.以下是我试图实现的伪代码:
{% include "includes/template.html" with info=if condition: a else: b %}
我在想我怎么才能做到这一点.如有任何建议或指导,我们将不胜感激!
我们可以在外部编写if条件,因此:
{% if condition %}
{% include "includes/template.html" with info=a %}
{% else %}
{% include "includes/template.html" with info=b %}
{% endif %}
根据具体情况,可能会以更短的方式完成此操作.