Node.js 翡翠,美信,&;html
我将jade用于node.js。我有1个混音器(测试): 我需要在mixin中输入一些html代码,例如:Node.js 翡翠,美信,&;html,node.js,mixins,pug,Node.js,Mixins,Pug,我将jade用于node.js。我有1个混音器(测试): 我需要在mixin中输入一些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
#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 )
#测试
-变量字段=“”;
-变量字段2=“”+描述+“”;
混合一些(字段,字段2)
对不起,我的英语不好:)看来你目前的解决方案是唯一的办法。mixin的参数是javascript表达式,而不是jade元素。实际上,您也可以将jade标记传递给mixin
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
我知道这个问题很老了。留下回复以便其他人可能会发现它有帮助
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