From 7e9e370e031c20e36a52c04a20dbbd7b4fe4672f Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Fri, 16 Oct 2009 17:28:29 -0700 Subject: Make encodings work with Erubis and 1.9 again --- actionpack/lib/action_view/template/handlers/erb.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_view/template') diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index 8993dd2b35..88aeb4b053 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -42,9 +42,11 @@ module ActionView self.erubis_implementation = Erubis def compile(template) - magic = $1 if template.source =~ /\A(<%#.*coding[:=]\s*(\S+)\s*-?%>)/ - erb = "#{magic}<% __in_erb_template=true %>#{template.source}" - self.class.erubis_implementation.new(erb, :trim=>(self.class.erb_trim_mode == "-")).src + source = template.source.gsub(/\A(<%(#.*coding[:=]\s*(\S+)\s*)-?%>)\s*\n?/, '') + erb = "<% __in_erb_template=true %>#{source}" + result = self.class.erubis_implementation.new(erb, :trim=>(self.class.erb_trim_mode == "-")).src + result = "#{$2}\n#{result}" if $2 + result end end end -- cgit v1.2.3