Bug #213
Different ERB behavior across versions
| Status: | Closed | Start date: | 07/02/2008 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 100% |
|
| Category: | - | |||
| Target version: | - | |||
| ruby -v: |
Description
I'm seeing some differences in ERB processing across 1.8.6, 1.8.7 and
1.9. 1.8.6 and 1.9 behave the same while 1.8.7 differs:
$ cat foo.rb
require 'erb'
str = <<'END'
<ul>
% list = [1,2,3]
%for item in list
% if item
<li><%= item %>
<% end %>
<% end %>
</ul>
%%%
END
p ERB.new(str, nil, "%").result
$ ruby -v foo.rb
ruby 1.8.6 (2008-06-29 patchlevel 255) [i686-darwin9.3.0]
"<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n"
$ ruby-1.9 -v foo.rb
ruby 1.9.0 (2008-06-10 revision 15929) [i686-darwin9.3.0]
"<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n"
$ ruby-1.8.7 -v foo.rb
ruby 1.8.7 (2008-05-31 patchlevel 0) [i686-darwin9.3.0]
"<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%"
In order:
# 1.8.6 => "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n"
# 1.9 => "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n"
# 1.8.7 => "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%"
I think this is a bug in 1.8.7 but I'd like some clarification.
Associated revisions
merge revision(s) 17881:
* lib/erb.rb (PercentScanner#scan): fix %% line bug. [ruby-core:17491]
* test/erb/test_erb.rb (test_percent): ditto.
History
Updated by shyouhei (Shyouhei Urabe) almost 4 years ago
卜部です。 以下のようなバグ報告がきています。1.8.7でなにやらエンバグしてしまってい るようなのですが... Federico Builes さんは書きました: > Issue #213 has been reported by Federico Builes. > > ---------------------------------------- > Bug #213: Different ERB behavior across versions > http://redmine.ruby-lang.org/issues/show/213 > > Author: Federico Builes > Status: Open > Priority: Normal > Assigned to: > Category: > Target version: > > > I'm seeing some differences in ERB processing across 1.8.6, 1.8.7 and > 1.9. 1.8.6 and 1.9 behave the same while 1.8.7 differs: > > $ cat foo.rb > require 'erb' > str = <<'END' > <ul> > % list = [1,2,3] > %for item in list > % if item > <li><%= item %> > <% end %> > <% end %> > </ul> > %%% > END > > p ERB.new(str, nil, "%").result > > > $ ruby -v foo.rb > ruby 1.8.6 (2008-06-29 patchlevel 255) [i686-darwin9.3.0] > "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n" > > $ ruby-1.9 -v foo.rb > ruby 1.9.0 (2008-06-10 revision 15929) [i686-darwin9.3.0] > "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n" > > $ ruby-1.8.7 -v foo.rb > ruby 1.8.7 (2008-05-31 patchlevel 0) [i686-darwin9.3.0] > "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%" > > In order: > > # 1.8.6 => "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n" > # 1.9 => "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n" > # 1.8.7 => "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%" > > I think this is a bug in 1.8.7 but I'd like some clarification. > > > ---------------------------------------- > You have received this notification because you have either subscribed to it, or are involved in it. > To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account > > > >
Updated by Anonymous almost 4 years ago
咳といいます。 On 2008/07/04, at 14:09, Urabe Shyouhei wrote: > 卜部です。 > > 以下のようなバグ報告がきています。1.8.7でなにやらエン > バグしてしまってい > るようなのですが... > ごめんなさい。ごめんなさい。ごめんなさい。 たしかに1.8.7で壊してしまったようです。 %%ではじまるときは特別だ、って仕様を忘れてました。 ruby_1_8にciしました。
Updated by rogerdpack (Roger Pack) almost 4 years ago
here's wishing require 'erb' template = ERB.new <<-EOF x is <%= x # this should work %> EOF x = 4 puts template.result(binding) worked :)
Updated by nobu (Nobuyoshi Nakada) almost 4 years ago
Hi, At Thu, 10 Jul 2008 10:01:25 +0900, Roger Pack wrote in [ruby-core:17714]: > here's wishing > require 'erb' > template = ERB.new <<-EOF > x is <%= x # this should work %> > EOF > x = 4 > puts template.result(binding) > > > worked :) It seems not to work even in 1.8.0, and 1.6 didn't have erb, it was since 1.7.3 and 1.7 was a development version. From which version do you say it's different? -- Nobu Nakada
Updated by shyouhei (Shyouhei Urabe) almost 4 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r18002.
Updated by rogerdpack (Roger Pack) almost 4 years ago
Referring to http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17403 for differences in versioning. Just adding my wish for it :) Some others have the same wish, apparently: http://pennysmalls.com/2008/06/29/rails-on-ruby-187/ Thanks! -R