aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template/handlers/erb.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/template/handlers/erb.rb')
-rw-r--r--actionpack/lib/action_view/template/handlers/erb.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb
index d773df7d29..aab7baf442 100644
--- a/actionpack/lib/action_view/template/handlers/erb.rb
+++ b/actionpack/lib/action_view/template/handlers/erb.rb
@@ -1,4 +1,3 @@
-require 'erb'
require 'active_support/core_ext/class/attribute_accessors'
module ActionView
@@ -16,7 +15,11 @@ 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
+ require 'erb'
+
+ 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