Project

General

Profile

Bug #1559

ERB single line comment does not work

Added by jyzhang (James Zhang) about 10 years ago. Updated almost 7 years ago.

Status:
Rejected
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9.7.0]
Backport:
[ruby-core:23682]

Description

=begin
In erb you're supposed to be able to do single line comments:

<% # this is a comment %>

However, this does not work in ruby 1.9.1.

Temporary work around is to put the '%>' on a newline:

<% # this comment works in 1.9.1
%>

Please see attached unit test.
=end


Files

test_erb.rb (313 Bytes) test_erb.rb test that passes in Ruby 1.8.6 but fails in Ruby 1.9.1 jyzhang (James Zhang), 06/03/2009 01:19 PM

Related issues

Has duplicate Ruby trunk - Bug #3146: ERB single line comment does not workRejected04/14/2010Actions

History

#1

Updated by bitsweat (Jeremy Daer) about 10 years ago

=begin
<%# this comment (no space between % and #) works in 1.9.1 %>

I think <% # (with a space) was a side effect not a feature.
=end

#2

Updated by yugui (Yuki Sonoda) almost 10 years ago

  • Assignee set to seki (Masatoshi Seki)

=begin

=end

#3

Updated by jfahrenkrug (Johannes Fahrenkrug) almost 10 years ago

=begin
Hi,

I just ran into this issue on ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] as well. The test_erb.rb test fails.
On ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0], however, it passes.

  • Johannes =end
#4

Updated by khelll (khaled alhabache) almost 10 years ago

=begin
This bug is somehow annoying specially when u move from ruby 1.8.6 to either 1.8.7 or 1.9 and working with rails, many comments in views files.....
=end

#5

Updated by rsalkeld (Robin Salkeld) about 9 years ago

=begin
This seems to be caused by removing \n from the regular expressions used in ERB::Compiler::SimpleScanner2:

stag_reg = /(.?)(<%%|<%=|<%#|<%|\z)/m
etag_reg = /(.
?)(%%>|%>|\z)/m

It looks like the original change was intended as an optimization, but unintentionally changed the behaviour. Restoring the \n's fixes it.

<%# may work for comments as well, but a lot of us have relied on the old behaviour, and I see no reason not to fix an accidental regression.
=end

#6

Updated by mame (Yusuke Endoh) about 9 years ago

  • Status changed from Open to Rejected

=begin
Hi,

The maintainer of erb (Masatoshi Seki) formally rejected this
ticket in [ruby-dev:40990].

Use <%# ... %>.

--
Yusuke Endoh mame@tsg.ne.jp
=end

Also available in: Atom PDF