[英]How to use {{{{raw-helper}}}} in a handlebars template
我有一个很好的车把模板。 我希望能够添加以下内容:
<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中删除整个脚本块。
根据Handlebars文档 ,原始块中的任何内容都应保持不变。
原始帮助程序未内置。注册后,模板应该可以使用。
Handlebars.registerHelper('raw', function(options) {
return options.fn(this);
});
{{{{raw}}}}
<script id="someTemplate" type="text/x-handlebars-template">
{{test}}
</script>
{{{{/raw}}}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.