Module: Haml::Template
Overview
The class that keeps track of the global options for Haml within Rails.
Instance Attribute Summary collapse
-
#options ⇒ Hash<Symbol, Object>
The options hash for Haml when used within Rails.
Instance Method Summary collapse
-
#try_enabling_xss_integration ⇒ Boolean
Enables integration with the Rails 2.2.5+ XSS protection, if it's available and enabled.
Instance Attribute Details
#options ⇒ Hash<Symbol, Object>
The options hash for Haml when used within Rails. See the Haml options documentation.
13 14 15 |
# File 'lib/haml/template.rb', line 13
def options
@options
end
|
Instance Method Details
#try_enabling_xss_integration ⇒ Boolean
Enables integration with the Rails 2.2.5+ XSS protection, if it's available and enabled.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/haml/template.rb', line 19
def try_enabling_xss_integration
return false unless ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe?
Haml::Template.options[:escape_html] = true
Haml::Util.module_eval {def rails_xss_safe?; true; end}
require 'haml/helpers/xss_mods'
Haml::Helpers.send(:include, Haml::Helpers::XssMods)
Haml::Precompiler.module_eval do
def precompiled_method_return_value_with_haml_xss
"(#{precompiled_method_return_value_without_haml_xss}).html_safe!"
end
alias_method :precompiled_method_return_value_without_haml_xss, :precompiled_method_return_value
alias_method :precompiled_method_return_value, :precompiled_method_return_value_with_haml_xss
end
true
end
|