aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/template.rb')
-rw-r--r--actionpack/lib/action_view/template.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index a1a970e2d2..ce249e2a96 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -27,6 +27,12 @@ module ActionView
end
def initialize(source, identifier, handler, details)
+ if source.encoding_aware? && source =~ %r{\A#{ENCODING_FLAG}}
+ # don't snip off the \n to preserve line numbers
+ source.sub!(/\A[^\n]*/, '')
+ source.force_encoding($1).encode
+ end
+
@source = source
@identifier = identifier
@handler = handler