Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add magic encoding comment to generated files

#955

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.

Reported by khelll · September 2nd, 2008 @ 11:48 AM

State: duplicate
Milestone: 2.x
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. khelll
    khelll

    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.

    September 2nd, 2008 @ 11:49 AM

  2. Jeremy Kemper
  3. Deleted User
    Deleted User
    • 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 <%

    December 20th, 2008 @ 08:32 PM

  4. Charlie Marx
    Charlie Marx
    • 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 %>

    January 3rd, 2009 @ 06:44 PM

  5. Jordan Brough
    Jordan Brough

    See #1580 Whitespace Bug in Erb Comments in Rails 2.2.2

    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

    January 28th, 2009 @ 01:58 PM

  6. ...
    ...

    Thank you Charlie. Correct usage always "fixes" problems, ey? :)

    October 20th, 2009 @ 02:55 AM

  7. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:11 PM

  8. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    October 11th, 2010 @ 12:13 PM

  9. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    October 21st, 2010 @ 03:39 AM

  10. Jeff Kreeftmeijer
  11. Jeff Kreeftmeijer
  12. Jeff Kreeftmeijer
  13. bingbing
  14. links london