mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Haml] Separate out Haml::Template.options and load it early under Rails 3.
Closes gh-148
This commit is contained in:
parent
d95e0cc45a
commit
647a095fa4
4 changed files with 25 additions and 9 deletions
|
@ -3,6 +3,13 @@
|
||||||
* Table of contents
|
* Table of contents
|
||||||
{:toc}
|
{: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
|
## 3.0.0.rc.3
|
||||||
|
|
||||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0.rc.3).
|
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0.rc.3).
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
|
|
||||||
# Rails 3.0.0.beta.2+
|
# Rails 3.0.0.beta.2+
|
||||||
if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
|
if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
|
||||||
|
require 'haml/template/options'
|
||||||
ActiveSupport.on_load(:action_view) {Haml.init_rails(binding)}
|
ActiveSupport.on_load(:action_view) {Haml.init_rails(binding)}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
require 'haml/template/options'
|
||||||
require 'haml/engine'
|
require 'haml/engine'
|
||||||
require 'haml/helpers/action_view_mods'
|
require 'haml/helpers/action_view_mods'
|
||||||
require 'haml/helpers/action_view_extensions'
|
require 'haml/helpers/action_view_extensions'
|
||||||
|
@ -5,15 +6,6 @@ require 'haml/helpers/action_view_extensions'
|
||||||
module Haml
|
module Haml
|
||||||
# The class that keeps track of the global options for Haml within Rails.
|
# The class that keeps track of the global options for Haml within Rails.
|
||||||
module Template
|
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,
|
# Enables integration with the Rails 2.2.5+ XSS protection,
|
||||||
# if it's available and enabled.
|
# if it's available and enabled.
|
||||||
#
|
#
|
||||||
|
|
16
lib/haml/template/options.rb
Normal file
16
lib/haml/template/options.rb
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue