ruby-on-railsrubycommentserbblock-comments

How does one comment in an erb template?


I have some trivial markup that looks like the following:

<li class="someclass">
  <=% t'model.attr' %>
</li>

Is there a trivial way to comment that out? Just wrapping <!-- --> around the block will still leave the ruby code available to the template. This means I have to comment out the HTML and Ruby specific code separately.

What's the best way to comment out all three lines with the least amount of markup?


Solution

  • =begin and =end are the Ruby version of block comments.

    Using them in an erb template:

    <%
    =begin
    %>
    <li class="someclass">
      <=% t'model.attr' %>
    </li>
    <%
    =end
    %>