Jade,mixin && html

我正在为node.js使用jade。 我有一个mixin(testing):

mixin some( field, field2 ) .field!= field .field2!= field2 

我需要把一些html代码混入,例如:

 #test some( a( href='http://test' )='test', span.description=description ) 

我要那个:

 <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> 

我可以怎么做? 现在我只知道一个丑陋的决定:

 #test - var field = '<a href="http://test">test</a>'; - var field2 = '<span class="description">' + descriptions + '</span>'; mixin some( field, field2 ) 

对不起,我的英语不好 :)

看起来你现在的解决scheme是唯一的方法。 mixin的参数是javascriptexpression式,而不是jade元素。

其实你也可以通过Jade的标记来混合

 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 

我知道这个问题是相当古老的。 留下回复,以便其他人可能会觉得有帮助。