ERB single line comment does not work
In erb you're supposed to be able to do single line comments:
<% # this is a comment %>
However, this does not work in ruby 1.9.1.
Temporary work around is to put the '%>' on a newline:
<% # this comment works in 1.9.1
Please see attached unit test.
Updated by rsalkeld (Robin Salkeld) over 9 years ago
This seems to be caused by removing \n from the regular expressions used in ERB::Compiler::SimpleScanner2:
stag_reg = /(.?)(<%%|<%=|<%#|<%|\z)/m
etag_reg = /(.?)(%%>|%>|\z)/m
It looks like the original change was intended as an optimization, but unintentionally changed the behaviour. Restoring the \n's fixes it.
<%# may work for comments as well, but a lot of us have relied on the old behaviour, and I see no reason not to fix an accidental regression.