Skip to content

Commit

Permalink
Make encodings work with Erubis and 1.9 again
Browse files Browse the repository at this point in the history
  • Loading branch information
wycats committed Oct 17, 2009
1 parent a223942 commit 7e9e370
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions actionpack/lib/action_view/template/handlers/erb.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ class ERB < TemplateHandler
self.erubis_implementation = Erubis self.erubis_implementation = Erubis


def compile(template) def compile(template)
magic = $1 if template.source =~ /\A(<%#.*coding[:=]\s*(\S+)\s*-?%>)/ source = template.source.gsub(/\A(<%(#.*coding[:=]\s*(\S+)\s*)-?%>)\s*\n?/, '')
erb = "#{magic}<% __in_erb_template=true %>#{template.source}" erb = "<% __in_erb_template=true %>#{source}"
self.class.erubis_implementation.new(erb, :trim=>(self.class.erb_trim_mode == "-")).src result = self.class.erubis_implementation.new(erb, :trim=>(self.class.erb_trim_mode == "-")).src
result = "#{$2}\n#{result}" if $2
result
end end
end end
end end
Expand Down

0 comments on commit 7e9e370

Please sign in to comment.