I'm using jade for node.js. I have 1 mixin(test):
mixin some( field, field2 )
.field!= field
.field2!= field2
I need put into mixin some html code, example:
#test
some( a( href='http://test' )='test', span.description=description )
I want that:
<div id="test">
<div class="field"><a href="http://test">test</a></div>
<div class="field2"><span class="description">bla bla bla</span></div>
</div>
How I may do that? Now I know only 1 ugly decision:
#test
- var field = '<a href="http://test">test</a>';
- var field2 = '<span class="description">' + descriptions + '</span>';
mixin some( field, field2 )
Sorry, for my bad english :)
Looks like your current solution is the only way. The parameters to a mixins are javascript expressions, not jade elements.
Actually you can pass Jade markup to mixin as well
mixin article(title)
.article
.article-wrapper
h1= title
if block
block
else
p No content provided
+article('Hello world')
+article('Hello world')
p This is my
p Amazing article
I know this question is quite old. Leaving reply so that someone else might find it helpful.
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