How to do multiline comment with conditional statements in ember.js script handlebars?

HaoQi Li picture HaoQi Li · May 29, 2013 · Viewed 11.7k times · Source

I'm learning ember.js and would like to sometimes deactivate some chunks of code. I know {{! }} works for single-line commenting inside <script type="text/x-handlebars">, but I can't make it work for multi-line commenting. Maybe because I have conditional statements inside.

<script type="text/x-handlebars" id="stuff">
    {{!
      {{#if length}}
        foobar
      {{/if}}
    }}
</script>

but then I got this error:

Uncaught Error: Parse error on line xx:
...ngth}}    foobar  {{/if}}}}    {{ o
---------------------^
Expecting 'EOF', got 'OPEN_ENDBLOCK' 

I also tried using <!-- ... -->, while the section is not shown, but I also get this error:

Uncaught Error: Cannot perform operations on a Metamorph that is not in the DOM

this error doesn't show up if I just delete that chunk of code.

Answer

selvagsz picture selvagsz · May 30, 2013

Add

{{!--
  This is a
  multiline
  comment
--}}

for multiline comments