【问题标题】:include into if with nunjucks in nodejs在 nodejs 中使用 nunjucks 包含在 if 中
【发布时间】:2017-04-07 13:50:54
【问题描述】:

我使用 nodejs 在用户系统上工作。 我用快递和双节棍。 我尝试在用户登录网站时呈现模板,并在用户注销时呈现另一个模板。

{% if isLoging %}
        {% include "toolbar_guest.html" %}
{% else %}
        {% include "toolbar_guest.html" %}
{% endif %}

但它不起作用... 如果我试试这个:

{% if isLoging %}
        connected
{% else %}
    not connected!
{% endif %}

它的工作..

【问题讨论】:

  • {% include 'toolbar_user.html' if isLogging else 'toolbar_guest.html' %}

标签: node.js templates express render nunjucks


【解决方案1】:
{% include 'toolbar_user.html' if isLogging else 'toolbar_guest.html' %}

【讨论】:

  • 虽然此代码 sn-p 可能是解决方案,但 including an explanation 确实有助于提高您的帖子质量。请记住,您是在为将来的读者回答问题,而这些人可能不知道您提出代码建议的原因。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-04
  • 1970-01-01
  • 2017-08-23
相关资源
最近更新 更多