【发布时间】:2015-06-30 05:07:23
【问题描述】:
我正在尝试检查调用 Jade mixin 时是否设置了参数。以下示例不起作用,我不明白为什么。
mixin foo(bar)
if bar
- var text = 'a'
else
- var text = 'another'
.hero-unit.macro-unit
p This is #{text} mixin.
// Calling mixin:
+foo
+foo(bar)
+foo
+foo(bar)
预期输出:
This is a mixin.
This is another mixin.
This is a mixin.
This is another mixin.
实际输出:
This is a mixin.
This is a mixin.
This is a mixin.
This is a mixin.
我也尝试按照this answer 中的建议将if bar 更改为if (typeof(username) !== 'undefined'),但没有骰子。我哪里错了?
【问题讨论】:
标签: javascript node.js templates pug gulp