Embedded Ruby

From WhyNotWiki

Jump to: navigation, search

[edit] [Comments in ERb]

Using =begin/=end seems to work for commenting out sections of ERB files. (http://woss.name/2006/05/07/notes-from-a-rails-course/0)

[edit] [Open complaint] [Comments in ERb] Using # for comments inside of a one-line <%= %> ERb block causes an error!

Example:

Throws an error:

<%= #pagination_links @order_pages %>

Doesn't throw an error:

<%= #pagination_links @order_pages 
%>

It seems like it's trying to comment out the %> delimiter.

But that doesn't make sense to me -- the %> isn't Ruby code, so it shouldn't be trying to comment it out! The <% and %> only mark where the actualy Ruby begins and ends.

Update: I think the standard way to comment out stuff in ERb is <%# rather than <%=# :

<%# #pagination_links @order_pages %>
Personal tools