This project is archived and is in readonly mode.

Comments in erb/rthml cause incorrect formatting
Reported by DavidT | September 8th, 2009 @ 04:34 AM
Comments in rhtml/erb code can cause the parser to behave
incorrectly.
For example:
  <% if true #comment %>
    <li><%= link_to "Announcements", :controller => "announcement", :action => "list" %></li>
  <% end -%>
  <li><%= link_to "Realview", :controller => "realview", :action => "refresh" %></li>
  <li><%= link_to "System Configuration", :controller => "system", :action => "configure" %></li>
Yields:
  <a href="/announcement/list">Announcements</a></li>    <----ERROR LINE
  <li><a href="/realview/refresh">Realview</a></li>
  <li><a href="/system/configure">System Configuration</a></li>
Note that the "
- " is missing from the beginning of "ERROR LINE".
Comments and changes to this ticket
- 
         CancelProfileIsBroken September 8th, 2009 @ 12:10 PM- State changed from new to invalid
 1) Putting # in the middle of an ERB code chunk to indicate a comment isn't supported by ERB. It used to work by accident under Ruby 1.8.6, but that's an implementation detail that changed in 1.8.7. The valid syntax for ERB comments is <%# comment -- ignored -- useful in testing %>see http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html and http://www.ruby-forum.com/topic/154835 2) If you want to propose a change in ERB itself, you need to go upstream; Rails is just an ERB consumer. 
- 
            
         Ian Moss October 28th, 2009 @ 11:33 AMI get the feeling this SHOULD be possible in Rails. In Ruby a comment is a # In Rails Erb I start a Ruby block of code with <% and finish it with %> To me, it seems logical that anything following a # should work as a ruby comment. 
 It shouldn't matter if there is whitespace before or not.Can someone point me towards the bit of rails core code that deals with comments, so I can fix this or branch or whatever is needed. I'm going to go off and search the rails git code base now - but am thinking someone may well read this before I find it. Thanks - Ian - http://twitter.com/oceanician 
- 
         CancelProfileIsBroken October 28th, 2009 @ 11:54 AMAgain, this isn't in Rails. ERB is responsible for handling those blocks. Once we hit the <% we're out of the Rails codebase. 
- 
            
         Ian Moss October 29th, 2009 @ 11:00 AMGreat - I'm new to the Rails codebase, whereabouts is the ERB code? 
 I've tried to search via GitHub but can't find it.
 Is their a contributors readme someplace I should be looking at ?
 Cheers,
 Ian.
 http://twitter.com/oceanician
- 
            
         Ian Moss October 29th, 2009 @ 11:14 AMAha - Ok so it helps understanding the R is Ruby not Rails for me :) 
 Found the erb within ruby:
 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/erb.rb?view=log1Ian 
- 
         Ryan Bigg October 9th, 2010 @ 09:56 PM- Tag cleared.
- Importance changed from  to Low
 Automatic cleanup of spam. 
- 
         
- 
         
- 
            
         
- 
            
         
- 
            
         
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
 CancelProfileIsBroken
      CancelProfileIsBroken
 Jeremy Kemper
      Jeremy Kemper
 Ryan Bigg
      Ryan Bigg