Templates 如果!Nunjuck中的真实条件渲染
Templates 如果!Nunjuck中的真实条件渲染,templates,nunjucks,Templates,Nunjucks,if…true条件句就像文档中的符咒一样工作 但如果我试着做以下事情: {% if !posts.length %} <i>No project posts yet!</i> {% endif %} 我通过以下方式解决了这个问题: {% if posts.length %} {% else %} <i>No project posts yet!</i> {% endif %} {%if posts.length%} {%else%} 还没有项目
if…true
条件句就像文档中的符咒一样工作
但如果我试着做以下事情:
{% if !posts.length %}
<i>No project posts yet!</i>
{% endif %}
我通过以下方式解决了这个问题:
{% if posts.length %}
{% else %}
<i>No project posts yet!</i>
{% endif %}
{%if posts.length%}
{%else%}
还没有项目帖子!
{%endif%}
有更好(正确)的方法吗?我看你有点眼花缭乱 尝试使用
而不是,而不是代码>
换句话说,使用而不是,而不是代码>
给他们一个go mate,注意在这里的原始部分,他们突出显示而不是,好像这是一个关键字
祝您好运。您可以使用以下语法:
<% '' if posts.length else 'No project posts yet!' %>
<% '' if posts.length else 'No project posts yet!' %>