diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-07-19 00:24:02 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-07-19 00:24:02 -0500 |
commit | 108ed4a5660d4ebdc52563250463c762e3f27988 (patch) | |
tree | faa937f626c6853a10a446d81c7b31ad0d7039a0 /actionpack | |
parent | c609be45966316bb107e0bad2b0935ac4a0d0c41 (diff) | |
download | rails-108ed4a5660d4ebdc52563250463c762e3f27988.tar.gz rails-108ed4a5660d4ebdc52563250463c762e3f27988.tar.bz2 rails-108ed4a5660d4ebdc52563250463c762e3f27988.zip |
Ruby 1.9: Strip encoding from ERB source since you can not change character encoding during a method
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/template_handlers/erb.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/template_handlers/erb.rb b/actionpack/lib/action_view/template_handlers/erb.rb index 2f2febaa52..3def949f1e 100644 --- a/actionpack/lib/action_view/template_handlers/erb.rb +++ b/actionpack/lib/action_view/template_handlers/erb.rb @@ -48,8 +48,11 @@ module ActionView self.erb_trim_mode = '-' def compile(template) - src = ::ERB.new(template.source, nil, erb_trim_mode, '@output_buffer').src - "__in_erb_template=true;#{src}" + src = ::ERB.new("<% __in_erb_template=true %>#{template.source}", nil, erb_trim_mode, '@output_buffer').src + + # Ruby 1.9 prepends an encoding to the source. However this is + # useless because you can only set an encoding on the first line + RUBY_VERSION >= '1.9' ? src.sub(/\A#coding:.*\n/, '') : src end end end |