【发布时间】:2018-10-16 20:32:53
【问题描述】:
我无法理解如何为具有两个变量的特定条件语句显示“不存在帖子”消息。
在此示例中,假设我有一个“动物”集合 - 在特定页面上,我想要一个显示“食草动物的灵长类动物”的部分:
{% for animal in site.animal %}
{% if animal.species == "primate" and animal.type == "herbivore" %}
{{ animal.content }}
{% endif %}
{% endfor %}
我想做的是这样的(伪代码):
{% if POSTS_EXIST_FOR_THIS_COMBO: (animal.species == "primate" and animal.type == "herbivore") %}
{% for animal in site.animal %}
{% if animal.species == "primate" and animal.type == "herbivore" %}
{{ animal.content }}
{% endif %}
{% endfor %}
{% else %}
There are no posts for this category.
{% endif %}
注意:这与this 之类的示例不同,因为我有两个参数要检查。有人可以提供有关语法的建议吗?
【问题讨论】: