Module | Haml::Template |
In: |
lib/haml/template.rb
|
The class that keeps track of the global options for Haml within Rails.
# File lib/haml/template.rb, line 30 30: def precompiled_method_return_value_with_haml_xss 31: "::Haml::Util.html_safe(#{precompiled_method_return_value_without_haml_xss})" 32: end
Enables integration with the Rails 2.2.5+ XSS protection, if it‘s available and enabled.
@return [Boolean] Whether the XSS integration was enabled.
# File lib/haml/template.rb, line 19 19: def try_enabling_xss_integration 20: return false unless ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe? 21: 22: Haml::Template.options[:escape_html] = true 23: 24: Haml::Util.module_eval {def rails_xss_safe?; true; end} 25: 26: require 'haml/helpers/xss_mods' 27: Haml::Helpers.send(:include, Haml::Helpers::XssMods) 28: 29: Haml::Precompiler.module_eval do 30: def precompiled_method_return_value_with_haml_xss 31: "::Haml::Util.html_safe(#{precompiled_method_return_value_without_haml_xss})" 32: end 33: alias_method :precompiled_method_return_value_without_haml_xss, :precompiled_method_return_value 34: alias_method :precompiled_method_return_value, :precompiled_method_return_value_with_haml_xss 35: end 36: 37: true 38: end