From 94911c7af7f2e1da0a23d64d2055b77bc1f6ece8 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 1 Jun 2009 12:33:49 -0700 Subject: Ensure ERB source begins with the encoding comment --- actionpack/lib/action_view/template/handlers/erb.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/template/handlers/erb.rb') 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 -- cgit v1.2.3