Ruby 1.8.7 and ERB gotcha
No comments
Dec 8th, 10:45 am, filed in Ruby
Dec
8
While pairing with Bo on a new project, we were stumped with an odd issue with random HTML going missing.
It turns out <% # comment %> is not the same as <%# comment %>. Using <%# comment %> also comments all HTML until the next %> on another line after the initial comment.
So:
<% # comment %> foo <%= 'hello' %> bar
Will print
hello bar
but
<%# comment %> foo <%= 'hello' %> bar
will print the intended result of
foo hello bar
Solution: Find and replace all instances of <% # with <%#.
Geek, gamer, developer, and a part-time ninja. I work at