[英]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.