简体   繁体   English

如何获取Handlebars.js块模板的原始文本?

[英]How to get raw text of a Handlebars.js block template?

I want to make this work: 我想做这个工作:

{{#definePartial "myPartial"}}
  Value: {{value}}
{{/definePartial}}

{{>myPartial this}}

But I can't figure out how to get the text from the definePartial block helper. 但是我不知道如何从definePartial块帮助器获取文本。 All I have is options.fn() , that would replace {{value}} with a value from the current context. 我所拥有的只是options.fn() ,它将用当前上下文中的值替换{{value}}

Is there a way to do this, without using <script> or other tag to store the partial? 有没有一种方法,而无需使用<script>或其他标签来存储部分文档呢?

This will work: 这将起作用:

{{{{definePartial "myPartial"}}}}
  Value: {{value}}
{{{{/definePartial}}}}

{{>myPartial this}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM