After playng for some time with jade I still can't understand advantages of jade mixins over plain javascript functions. I found a disadvantage, however: I can't find a way to assign a mixin to a variable and then call it indirectly (I know the hack with jade_mixins[name_of_mixin] but it is unreliable, implementation-dependent and ugly)
So my questions are:
1) Is it possible to assign a mixin to variable/property and then call it indirectly?
2) Are there any advantages of mixins over functions at all except of syntactic sugar in declaration head?
Yes, you can use normal #{..}
interpolation syntax to dynamically call a mixin.
div
+#{templateName}(templateArgument)
The fact that jade mixins are implemented as functions is an implementation detail. One can use jade and jade-mixins without having to know javascript - so the syntax sugar may be helpful for template authors who see jade as an alternative syntax to html (rather than a javascript based templating system).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.