我想弄清楚 mustache 中的偏音是如何工作的。
JS
var mustacheTmpl = Mustache.render(popups, {list:true});
弹出模板
{{#list}}
<ul class="pending-job-list">
<li>test</li>
</ul>
{{/list}}
现在我想把他的列表放在同一个模板(弹出窗口)的一些标记中并渲染它
{{#outer}}
<div class="outerPopup">
// I want to render the list inside here
</div>
{{/outer}}
我该如何实现?
最佳答案
给你:
var partial = "{{#list}}"+
"<ul class=\"pending-job-list\">"+
"<li>{{.}}</li>"+
"</ul>"+
"{{/list}}";
var template = "{{#outer}}"+
"<div class=\"outerPopup\">"+
"{{>list}}"+
"</div>"+
"{{/outer}}";
var html = Mustache.render(template, { outer: {list:["test"]} }, { list:partial });
关于mustache - mustache.js 中的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21932085/