Sha256: cf50384984a80d7710888904ce2e0aee6dbb463ab3b4eb244154f44f04bce3dd

Contents?: true

Size: 1.73 KB

Versions: 12

Compression:

Stored size: 1.73 KB

Contents

require 'haml/engine'

module Haml
  # The class that keeps track of the global options for Haml within Rails.
  module Template
    extend self

    @options = {}
    # The options hash for Haml when used within Rails.
    # See {file:HAML_REFERENCE.md#haml_options the Haml options documentation}.
    #
    # @return [Hash<Symbol, Object>]
    attr_accessor :options
  end
end

if defined?(RAILS_ENV) && RAILS_ENV == "production"
  Haml::Template.options[:ugly] = true
end

# Decide how we want to load Haml into Rails.
# Patching was necessary for versions <= 2.0.1,
# but we can make it a normal handler for higher versions.
if defined?(ActionView::TemplateHandler)
  require 'haml/template/plugin'
else
  require 'haml/template/patch'
end

if ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe?
  Haml::Template.options[:escape_html] = true

  module Haml::Util
    def rails_xss_safe?
      true
    end
  end

  require 'haml/helpers/xss_mods'
  module Haml::Helpers
    include XssMods
  end
end

if defined?(RAILS_ROOT)
  # Update init.rb to the current version
  # if it's out of date.
  #
  # We can probably remove this as of v1.9,
  # because the new init file is sufficiently flexible
  # to not need updating.
  rails_init_file = File.join(RAILS_ROOT, 'vendor', 'plugins', 'haml', 'init.rb')
  haml_init_file = Haml::Util.scope('init.rb')
  begin
    if File.exists?(rails_init_file)
      require 'fileutils'
      FileUtils.cp(haml_init_file, rails_init_file) unless FileUtils.cmp(rails_init_file, haml_init_file)
    end
  rescue SystemCallError
    warn <<END
HAML WARNING:
#{rails_init_file} is out of date and couldn't be automatically updated.
Please run `haml --rails #{File.expand_path(RAILS_ROOT)}' to update it.
END
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
haml-edge-2.3.62 lib/haml/template.rb
haml-edge-2.3.61 lib/haml/template.rb
haml-edge-2.3.60 lib/haml/template.rb
haml-edge-2.3.59 lib/haml/template.rb
haml-edge-2.3.58 lib/haml/template.rb
haml-edge-2.3.57 lib/haml/template.rb
haml-edge-2.3.56 lib/haml/template.rb
haml-edge-2.3.55 lib/haml/template.rb
haml-edge-2.3.54 lib/haml/template.rb
haml-edge-2.3.53 lib/haml/template.rb
haml-2.2.9 lib/haml/template.rb
haml-edge-2.3.52 lib/haml/template.rb