Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Failing with comments in erubis


  • Please log in to reply
2 replies to this topic

#1 Ohm

Ohm

    Guard

  • Members
  • 186 posts
  • LocationCopenhagen

Posted 07 November 2013 - 09:06 PM

This spring I had a weird discovery within my erb-files.

When I wrote a comment like

SOME STUFF
STUFF <% # comment %>
MORE STUFF

It broke with a SyntaxError!

 

However, if the comment was on its own line, it didn't

THIS WILL
<% # comment %>
WORK 

I wrote a small blog post about it here, if you'd like to read more about it:

http://omegahm.githu...-in-erubis.html


Blog: http://ohm.sh | Twitter: madsohm


#2 Jamie

Jamie

    Controller

  • Moderators
  • 114 posts
  • LocationThe UK

Posted 12 November 2013 - 08:37 AM

This is rather funny and on time as the other day my colleague was having the same issue. I laughed at him because I just assumed he was being stupid and carried on. It was a Monday morning!

 

I usually do my comments in HTML still. Believe it or not the front-end guys here get scared at Ruby and can't for a minute even try looking at the Rails documentation.

 

That's a good share. I'll pass it onto my colleague and maybe he'll laugh back and call me the stupid one :P


Rails developer based in Newcastle, UK.
Web app owner - Twitter lover

#3 Ohm

Ohm

    Guard

  • Members
  • 186 posts
  • LocationCopenhagen

Posted 15 November 2013 - 09:56 PM

Found another weird thing with erubis. Wrote about it here: http://omegahm.githu...g-comments.html

 

Essentially your last printing statement (<%=) in the file can't end with a comment. That is this will break

<%= "the string" # yes, the string %>

But this will not

<% var = "the string" # yes, the string %>
<%= var %>

Blog: http://ohm.sh | Twitter: madsohm





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users