Sha256: 3efa3030f9e0b11b4cfa1bf03f7a985cfda26d87a73545744d32450ed3c010dc

Contents?: true

Size: 1.36 KB

Versions: 21

Compression:

Stored size: 1.36 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

# 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 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

21 entries across 21 versions & 1 rubygems

Version Path
haml-edge-2.1.32 lib/haml/template.rb
haml-edge-2.1.33 lib/haml/template.rb
haml-edge-2.1.34 lib/haml/template.rb
haml-edge-2.1.35 lib/haml/template.rb
haml-edge-2.1.36 lib/haml/template.rb
haml-edge-2.1.37 lib/haml/template.rb
haml-edge-2.1.38 lib/haml/template.rb
haml-edge-2.1.39 lib/haml/template.rb
haml-edge-2.1.40 lib/haml/template.rb
haml-edge-2.1.41 lib/haml/template.rb
haml-edge-2.1.42 lib/haml/template.rb
haml-edge-2.1.43 lib/haml/template.rb
haml-edge-2.1.44 lib/haml/template.rb
haml-edge-2.1.45 lib/haml/template.rb
haml-edge-2.1.46 lib/haml/template.rb
haml-edge-2.1.47 lib/haml/template.rb
haml-edge-2.1.48 lib/haml/template.rb
haml-edge-2.1.49 lib/haml/template.rb
haml-edge-2.1.50 lib/haml/template.rb
haml-edge-2.1.51 lib/haml/template.rb