I'm trying to check whether a parameter was set when calling a Jade mixin. The following example does not work and I don't understand why.
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)
Expected output:
This is a mixin.
This is another mixin.
This is a mixin.
This is another mixin.
Actual output:
This is a mixin.
This is a mixin.
This is a mixin.
This is a mixin.
I've also tried changing if bar
to if (typeof(username) !== 'undefined')
as suggested in this answer, but no dice. Where am I going wrong?