How to make a comment in haml? When "- #" in the line, the conversion of haml to html is interrupted and does not see nested tables:

!!! %html %head %title Заголовок %body %table -# Table 1- Main %tr %td %table -# Table 2 %tr %td 1 %td 2 %tr %td %table -# Table 3 %tr %td 3 %td 4 

The same happens when using gem haml-rails in Ruby on Rails that I use. Tell me what I did wrong.

    2 answers 2

     -# Table 1- Main 

    you just need to replace

     / Table 1- Main 

    However, it should be noted that this will comment out the entire table. To eliminate this, simply swap the lines:

     / Table 1- Main %table 

    And at the output we get:

      <!-- Table 1- Main --> <table> 

    Here is another good example of commenting in haml:

     - @foo = 42 #test1 / Hello #{@foo} #test2 <!-- Hello #{@foo} --> 

    At the exit:

     <div id='test1'> <!-- Hello 42 --> </div> <div id='test2'> <!-- Hello 42 --> </div> 
    • Is there a way not to display a comment in html, leaving it in a file with haml? - discipleartem
    • Well, this icon - # is an internal comment, you just most likely need to remove the indents, or the web interface that you do not use them for some reason or they do not reach it - igumnov
    • I saw because of what it is: because there are extra indents. The comment indent "- #", which is above, should not be more and less than the indentation of the next line. - discipleartem

    I saw because of what it is: because there are extra indents. The comment indent "- #", which is above, should not be more and less than the indentation of the next line.

    Examples when "- #" does not work:

     %body -# Table 1- Main */ -2 пробела */ %table %tr 

    and

     %body -# Table 1- Main */1 пробел лишний*/ %table %tr 

    right:

     %body -# Table 1- Main %table %tr