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?
Mixins in Jade are much like functions/methods in many other programming languages. Basically, if you're repeating your code at many places, you could place that code inside a mixin and replace your code with the mixin call. This would make your code cleaner and maintainable over long run.
Jade is a template engine for node. js and the default rendering engine for the Express web framework. It is a new, simplified language that compiles into HTML and is extremely useful for web developers. Jade is designed primarily for server-side templating in node.
It's used to produce XML documents like (HTML, RSS etc.), so we can't use it to create the plain text like HTML/CSS other documents. Jade Template Engine is used to make the template more beautiful and more meaningful with the help of description and their layout.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With