Skip to content

Commit

Permalink
[Haml] Separate out Haml::Template.options and load it early under Ra…
Browse files Browse the repository at this point in the history
…ils 3.

Closes sassgh-148
  • Loading branch information
nex3 committed May 1, 2010
1 parent d95e0cc commit 647a095
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
7 changes: 7 additions & 0 deletions doc-src/HAML_CHANGELOG.md
Expand Up @@ -3,6 +3,13 @@
* Table of contents
{:toc}

## 3.0.0.rc.4 (Unreleased)

### Rails Beta Support

* Setting options via `Haml::Template.options` in the initializer
now works without using `ActiveSupport.on_load(:action_view)`.

## 3.0.0.rc.3

[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0.rc.3).
Expand Down
1 change: 1 addition & 0 deletions lib/haml/railtie.rb
Expand Up @@ -5,5 +5,6 @@

# Rails 3.0.0.beta.2+
if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
require 'haml/template/options'
ActiveSupport.on_load(:action_view) {Haml.init_rails(binding)}
end
10 changes: 1 addition & 9 deletions lib/haml/template.rb
@@ -1,19 +1,11 @@
require 'haml/template/options'
require 'haml/engine'
require 'haml/helpers/action_view_mods'
require 'haml/helpers/action_view_extensions'

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 [{Symbol => Object}]
attr_accessor :options

# Enables integration with the Rails 2.2.5+ XSS protection,
# if it's available and enabled.
#
Expand Down
16 changes: 16 additions & 0 deletions lib/haml/template/options.rb
@@ -0,0 +1,16 @@
# We keep options in its own self-contained file
# so that we can load it independently in Rails 3,
# where the full template stuff is lazy-loaded.

module Haml
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 [{Symbol => Object}]
attr_accessor :options
end
end

0 comments on commit 647a095

Please sign in to comment.