This project is archived and is in readonly mode.
Add magic encoding comment to generated files
Reported by khelll | September 2nd, 2008 @ 11:48 AM | in 2.x
I got this problem while working with rails 2.1 and ruby 1.8.7
when adding a comment at the end of <%%> , you get an odd way of rendering , look at line 3 in the attached file and try to run this view file using both ruby 1.8.7 and ruby 1.8.6.
Comments and changes to this ticket
-
khelll September 2nd, 2008 @ 11:49 AM
I got this problem while working with rails 2.1 and ruby 1.8.7
when adding a comment at the end of <%%> , you get an odd way of rendering , look at line 3 in the attached file and try to run this view file using both ruby 1.8.7 and ruby 1.8.6.
-
Jeremy Kemper September 2nd, 2008 @ 12:00 PM
- State changed from new to duplicate
-
Deleted User December 20th, 2008 @ 08:32 PM
- Tag set to ruby 1.8.7, erb
I've seen this bug as well. It still happens on rails 2.2.2, under ruby 1.8.7.
In my case, I was a adding a one-line comment to a view, like this:
<% #TODO: something to do... %>
It looks like the following HTML code is ignored until the next <%
-
Charlie Marx January 3rd, 2009 @ 06:44 PM
- Tag changed from ruby 1.8.7, erb to ruby 1.8.7, comment, erb
Just struggled with this after upgrading to Ruby 1.8.7 and Rails 2.2.2.
Here is a relevant portion from the inline documentation for ERB:
| ERB recognizes certain tags in the provided template and converts them based on the rules below: | | <% Ruby code -- inline with output %> | <%= Ruby expression -- replace with result %> | <%# comment -- ignored -- useful in testing %> | % a line of Ruby code -- treated as <% line %> (optional -- see ERB.new) | %% replaced with % if first thing on a line and % processing is used | <%% or %%> -- replace with <% or %> respectively
So, contrary to some suggestions (http://www.ruby-forum.com/topic/...), comments ARE allowed in ERB, but it seems to be safe only to do so when the whole embedded expression is a comment, i.e.:
<%# this is good comment %>
<% n=1 # this is a bad comment %>
If your 'bad comments' are consistent in their usage of whitespace around the hash mark, then it ought to be easy to do a grep search-and-replace to change all your bad comments to look like this, which WILL work in Ruby 1.8.7:
<% n=1 %><%# this is the fixed comment %>
-
Jordan Brough January 28th, 2009 @ 01:58 PM
See #1580
Comments aren't supported, only comment tags are. It has to do with the fact that it's a special tag, not with whether the whole line is commented or not. e.g. --
ruby -v -rerb -e 'p ERB.new("<%# test %>foobar").result'
correctly gives 'foobar'. while
ruby -v -rerb -e 'p ERB.new("<% # test %>foobar").result'
gives an empty string in 1.8.6 and 1.8.7
-
Ryan Bigg October 9th, 2010 @ 10:11 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>