Permalink
Browse files

Make encodings work with Erubis and 1.9 again

  • Loading branch information...
1 parent a223942 commit 7e9e370e031c20e36a52c04a20dbbd7b4fe4672f @wycats wycats committed Oct 17, 2009
Showing with 5 additions and 3 deletions.
  1. +5 −3 actionpack/lib/action_view/template/handlers/erb.rb
View
8 actionpack/lib/action_view/template/handlers/erb.rb
@@ -42,9 +42,11 @@ class ERB < TemplateHandler
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

0 comments on commit 7e9e370

Please sign in to comment.