When calling a mixin in Jade, what's the difference between "+" and mixin keyword?
Problem
The docmentation tells us to call a Mixin by prepending the keyword mixin
to the actual mixin.
.bar
mixin foo(arguments)
But on different places I saw people calling a mixin by prepending a plus (+) sign, like:
.bar
+foo(arguments)
Could someone please explain the difference since the documentation does not seem to show it. I tried both examples and both seemed to work.
Is +
just a shorthand?
Solution
Yes, it appears so. If you look at lib/lexer.js
in the Call mixin
section, you can see that terms beginning with a +
get tokenized with type call
. Later in lib/parser.js
the call
token causes parseCall
to create a new mixin invocation node.
Furthermore the commit was made with with the comment:
Added preliminary mixin block support and the new + mixin invocation syntax.
Discussion
View additional discussion.