aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template_handlers/erb.rb
blob: 022fc362e76288c95858b0d20399b761cc8c9326 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'erb'

class ERB
  module Util
    HTML_ESCAPE = { '&' => '&amp;', '"' => '&quot;', '>' => '&gt;', '<' => '&lt;' }

    def html_escape(s)
      s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
    end
  end
end

module ActionView
  module TemplateHandlers
    class ERB < TemplateHandler
      def compile(template)
        ::ERB.new(template, nil, @view.erb_trim_mode).src
      end
    end
  end
end