Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 676
HaoQi Li Avatar asked May 29 '13 19:05

HaoQi Li


People also ask

How do you comment out multiple lines in Javascript?

Multiline (Block) Comments Javascript multiline comments, also known as block comments, start with a forward slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/). They do not require a comment delimiter character on every line and may contain newlines.

How do you comment out handlebars?

Just add an exclamation mark after the opening brackets. Note that the difference between {{! and {{! -- forms is that only the latter allows embedded handlebars tags. As that will be easy to forget, especially in a long comment that is later revised, I would suggest to always use the longer comment form.

What is the proper command for multi line comment?

To comment out multiple lines in Python, you can prepend each line with a hash ( # ).


1 Answers

Add

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

for multiline comments

like image 82
selvagsz Avatar answered Dec 06 '22 09:12

selvagsz