diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-06-01 12:33:49 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-06-01 12:34:08 -0700 |
commit | 94911c7af7f2e1da0a23d64d2055b77bc1f6ece8 (patch) | |
tree | 72c5ee6df180bdc1a9009be10feae8ccff940800 /actionpack/lib/action_view/template/handlers | |
parent | 9537fd0e3a7625afe4bee75d749647ca1837195a (diff) | |
download | rails-94911c7af7f2e1da0a23d64d2055b77bc1f6ece8.tar.gz rails-94911c7af7f2e1da0a23d64d2055b77bc1f6ece8.tar.bz2 rails-94911c7af7f2e1da0a23d64d2055b77bc1f6ece8.zip |
Ensure ERB source begins with the encoding comment
Diffstat (limited to 'actionpack/lib/action_view/template/handlers')
-rw-r--r-- | actionpack/lib/action_view/template/handlers/erb.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index d773df7d29..21272ef089 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -16,7 +16,9 @@ module ActionView self.default_format = Mime::HTML def compile(template) - ::ERB.new("<% __in_erb_template=true %>#{template.source}", nil, erb_trim_mode, '@output_buffer').src + magic = $1 if template.source =~ /\A(<%#.*coding:\s*(\S+)\s*-?%>)/ + erb = "#{magic}<% __in_erb_template=true %>#{template.source}" + ::ERB.new(erb, nil, erb_trim_mode, '@output_buffer').src end end end |