【发布时间】:2015-11-14 02:25:51
【问题描述】:
我有一个很好用的车把模板。我希望能够将以下内容放入其中:
<script id="someTemplate" type="text/x-handlebars-template">
<div class="editStuff">
<span {{#if aThing}} data-someKey="{{anotherThing}}" {{/if}}>
{{aThirdThing}}
</span>
</div>
</script>
这显然会在处理车把文件时呈现。所有的 {{}} 最终都是空白的,不好。我找到了
{{{{raw-helper}}}}
block helper,并尝试如下:
{{{{raw-helper}}}}
<script id="someTemplate" type="text/x-handlebars-template">
<div class="editStuff">
<span {{#if aThing}} data-addresskey="{{anotherThing}}" {{/if}}>
{{aThirdThing}}
</span>
</div>
</script>
{{{{/raw-helper}}}}
但这最终会从 HTML 中删除整个脚本块。
根据Handlebars docs,原始块中的任何内容都应保持不变。
【问题讨论】:
-
以防万一这不是内置帮助程序,我还尝试在文档页面的示例中注册处理程序。不好。很难判断车把 API 中包含和未包含的内容。