Best way to add comments in erb

前端 未结 7 1902
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 06:45

How do we add comments in erb files, if we do not want them to be generated into the html content?

相关标签:
7条回答
  • 2020-12-04 06:51

    For Record

    <%# This is a great comment! %>
    
    <%#= This is a great comment! %>
    
    0 讨论(0)
  • 2020-12-04 06:59

    In my text editor, i run command + / (sublime-text shortcut). It will be like this.

    <%
    =begin%>
        Here is the comment 
    <%
    =end%>
    

    It doesn't look simply, but it works.

    0 讨论(0)
  • 2020-12-04 06:59

    I doesn't work in the Controllers files, I had to put it between slashes

    / comment here.... /

    0 讨论(0)
  • 2020-12-04 07:08

    Since .erb is by definition "embedded ruby", you can embed every ruby code between: <%= and the other: %>, typically all written in one line. In addition, ruby one-line comments start always with #, so the <%=# Comment %> style matches perfectly with both pure-ruby and erb styles for one-line comments.

    0 讨论(0)
  • 2020-12-04 07:09

    For block comments:

    <% if false %>
        code to be commented out...
    <% end %> 
    
    0 讨论(0)
  • 2020-12-04 07:15

    I have a Windows setup, and this <%-# %> sequence is the only one that works for me:

    Example:

    <%-# This is a sample comment! %>
    
    0 讨论(0)
提交回复
热议问题