有没有办法让胡须展开变量内的标签?在变量内展开标签
我知道这是偏分的目的。但是,正如您在下面的示例中看到的那样,由于视图的结构,使用偏分组有时不切实际。
如果不是,我应该如何更改下面的视图结构?目前,我预先提供了每个条目的html
属性。这看起来并不理想(并且打破了改变胡须的分隔符等功能)。
例
一个博客的主页视图:
var view = {
title: 'Example blog',
entries: [
{url: '/a', html: '<p>The first entry on {{title}}</p>'},
{url: '/b', html: '<p>The second entry on {{title}}</p>'},
{url: '/c', html: '<p>The third entry on {{title}}</p>'}
]
};
相应的模板:
{{#entries}}
{{{html}}}
{{/entries}}
调用Mustache.render
后,我收到此。
<p>The first entry on {{title}}</p>
<p>The second entry on {{title}}</p>
<p>The third entry on {{title}}</p>
而且我希望收到此:
<p>The first entry on Example blog</p>
<p>The second entry on Example blog</p>
<p>The third entry on Example blog</p>
对不起,我应该更清楚。我们不能假定每个条目的HTML都是如此重复 - 它们是博客帖子,其中一些包含胡须标签。 – davidmerfield