Handlebars {{{{}}}} 有什么作用?

what does Handlebars {{{{}}}} do?

我想了解 {X4 是什么意思。 Handlebars 网站上有一个示例: http://handlebarsjs.com/block_helpers.html 最后一个例子是:

Raw Blocks

Raw blocks are available for templates needing to handle unprocessed mustache blocks. {{{{raw-helper}}}} {{bar}} {{{{/raw-helper}}}} will execute the helper raw-helper without interpretting the content. Handlebars.registerHelper('raw-helper', function(options) { return options.fn(); }); will render {{bar}}

{{{}}} 块内的数据未被处理并显示为原始(原样),最重要的是 不是 html-escapedhttp://handlebarsjs.com/expressions.html ).

示例(仅供说明):

{{{<span></span>}}} 输出 <span></span>

{{<span></span>}} 输出 &lt;span&gt;&lt;/span&gt;

具有 4 个 {{{{}}}} (http://handlebarsjs.com/block_helpers.html) 的原始块提供与上述类似的功能,但用于块声明。这意味着块内的所有内容都将按原样输出。

这只是符号的一种变体,我想是为了让编译更容易,因为 3 {{{}}} 标签对于原始标签已经有了固定的含义

这实现的另一个功能是元模板,这意味着模板可以输出另一个模板代码(使用相同的语言,即 handlebars),然后将其用作普通模板。例如从服务端渲染到客户端渲染(我认为这个github issue and this与车把中raw blocks声明的引入有关)