0

Code is executed inside HTML comment tags (<!-- some comment -->), whereas <%# %> works as comments. In addition to that, "best way to add comments in erb" says that there are two options: one uses the = sign, that is, <%#= %>, but it does not mention the difference. What is the difference between the two?


EDIT: corrected the code I pasted here to be as in the referenced link

heretoinfinity
  • 1,528
  • 3
  • 14
  • 33
  • 1
    both of them are comments – max pleaner Aug 07 '17 at 03:27
  • I realize that but what is the difference between the two? Could you also make your comment an answer? – heretoinfinity Aug 07 '17 at 03:56
  • 3
    The difference is the same as the difference between `# Pancakes!` and `#= Pancakes!` in some plain old Ruby code (i.e. none that Ruby cares about). BTW, Salil is using `<%#= ... %>` not `<%#= ... =%>` in their second example and that's just turning a `<%= ... %>` ERB directive into a comment. – mu is too short Aug 07 '17 at 03:59

1 Answers1

0

Thanks to 'max pleaner' and 'mu is too short' for the answer in the comments.

Both are comments but the '=' sign implies that this comment was made to be rendered in the window previously but the writer decided to comment it out. This way the coder could go back and undo things with just a single delete.

heretoinfinity
  • 1,528
  • 3
  • 14
  • 33