如何在ember.js脚本句柄中使用条件语句进行多行注释?

Hao*_* Li 21 handlebars.js ember.js

我正在学习ember.js,并希望有时会停用一些代码块.我知道{{! }}内部有单行注释<script type="text/x-handlebars">,但我不能让它适用于多行注释.也许是因为我内部有条件陈述.

<script type="text/x-handlebars" id="stuff">
    {{!
      {{#if length}}
        foobar
      {{/if}}
    }}
</script>
Run Code Online (Sandbox Code Playgroud)

但后来我收到了这个错误:

Uncaught Error: Parse error on line xx:
...ngth}}    foobar  {{/if}}}}    {{ o
---------------------^
Expecting 'EOF', got 'OPEN_ENDBLOCK' 
Run Code Online (Sandbox Code Playgroud)

我也试过使用<!-- ... -->,虽然没有显示该部分,但我也得到了这个错误:

未捕获错误:无法对不在DOM中的Metamorph执行操作

如果我只删除那段代码,则不会显示此错误.

sel*_*gsz 52

{{!--
  This is a
  multiline
  comment
--}}
Run Code Online (Sandbox Code Playgroud)

用于多行评论


ear*_*lee 6

任何必须包含}}或其他句柄标记的注释都应使用{{! - - }}语法.

来源:http://handlebarsjs.com/

因此{{! }},只要其中没有其他车把令牌,它看起来对多线有效.否则,{{!-- --}}是必要的.