Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

When calling a mixin in Jade, what's the difference between "+" and mixin keyword?

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?

Problem courtesy of: Saucier

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.

Solution courtesy of: David Weldon

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

When calling a mixin in Jade, what's the difference between "+" and mixin keyword?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×