Module Haml::Template
In: lib/haml/template/options.rb
lib/haml/template.rb

The class that keeps track of the global options for Haml within Rails.

Methods

Attributes

options  [RW]  The options hash for Haml when used within Rails. See {file:HAML_REFERENCE.md#haml_options the Haml options documentation}.

@return [{Symbol => Object}]

Public Instance methods

[Source]

    # File lib/haml/template.rb, line 28
28:         def precompiled_method_return_value_with_haml_xss
29:           "::Haml::Util.html_safe(#{precompiled_method_return_value_without_haml_xss})"
30:         end

[Source]

    # File lib/haml/template.rb, line 22
22:                               def rails_xss_safe?; true; 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.

[Source]

    # File lib/haml/template.rb, line 13
13:     def try_enabling_xss_integration
14:       return false unless (ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe?) ||
15:         # We check for ActiveSupport#on_load here because if we're loading Haml that way, it means:
16:         # A) we're in Rails 3 so XSS support is always on, and
17:         # B) we might be in Rails 3 beta 3 where the load order is broken and xss_safe? is undefined
18:         (defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load))
19: 
20:       Haml::Template.options[:escape_html] = true
21: 
22:       Haml::Util.module_eval {def rails_xss_safe?; true; end}
23: 
24:       require 'haml/helpers/xss_mods'
25:       Haml::Helpers.send(:include, Haml::Helpers::XssMods)
26: 
27:       Haml::Precompiler.module_eval do
28:         def precompiled_method_return_value_with_haml_xss
29:           "::Haml::Util.html_safe(#{precompiled_method_return_value_without_haml_xss})"
30:         end
31:         alias_method :precompiled_method_return_value_without_haml_xss, :precompiled_method_return_value
32:         alias_method :precompiled_method_return_value, :precompiled_method_return_value_with_haml_xss
33:       end
34: 
35:       true
36:     end

[Validate]