Sha256: abf20f19514e755455ac06ffd27011d773cfece8bb7d5297a8df8e83bdd916d6

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# Haml 5.0 and 5.1 fall back to erb
if Haml::VERSION < '5'
  # Use module_eval so we crash when Haml::Helpers has not yet been loaded.
  Haml::Helpers.module_eval do

    def html_escape_with_escaping_angular_expressions(s)
      s = s.to_s
      if s.html_safe?
        s
      else
        html_escape_without_escaping_angular_expressions(AngularXss::Escaper.escape(s))
      end
    end

    alias_method :html_escape_without_escaping_angular_expressions, :html_escape
    alias_method :html_escape, :html_escape_with_escaping_angular_expressions
  end

elsif Haml::VERSION >= '5.2' 
  Haml::Helpers.module_eval do

    def html_escape_without_haml_xss_with_escaping_angular_expressions(s)
      s = s.to_s
      return s if s.html_safe?

      html_escape_without_haml_xss_without_escaping_angular_expressions(AngularXss::Escaper.escape(s))
    end

    alias_method :html_escape_without_haml_xss_without_escaping_angular_expressions, :html_escape_without_haml_xss
    alias_method :html_escape_without_haml_xss, :html_escape_without_haml_xss_with_escaping_angular_expressions
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
angular_xss-0.4.1 lib/angular_xss/haml.rb
angular_xss-0.4.0 lib/angular_xss/haml.rb