我有一个效果很好的车把模板。我希望能够将以下内容放入其中:
<script id="someTemplate" type="text/x-handlebars-template">
<div class="editStuff">
<span {{#if aThing}} data-someKey="{{anotherThing}}" {{/if}}>
{{aThirdThing}}
</span>
</div>
</script>
这显然会在处理车把文件时呈现。所有的 {{}} 最终都是空白的,这不好。我找到了
{{{{raw-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 中删除整个脚本块。
根据车把文档 http://handlebarsjs.com/block_helpers.html#raw-blocks原始块中的任何内容都应该保持不变。
raw-helper 不是内置的。注册后,模板应该可以工作。
Handlebars.registerHelper('raw', function(options) {
return options.fn(this);
});
{{{{raw}}}}
<script id="someTemplate" type="text/x-handlebars-template">
{{test}}
</script>
{{{{/raw}}}}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)