mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Abstracted out Rails environment to Haml::Util to allow backwards compatability.
This commit is contained in:
parent
cc8b27d930
commit
32f7eba94d
3 changed files with 14 additions and 3 deletions
|
@ -39,7 +39,7 @@ module Haml
|
|||
end
|
||||
end
|
||||
|
||||
if defined?(RAILS_ENV) && RAILS_ENV == "production"
|
||||
if Haml::Util.rails_env == "production"
|
||||
Haml::Template.options[:ugly] = true
|
||||
end
|
||||
|
||||
|
|
|
@ -146,6 +146,17 @@ module Haml
|
|||
return nil
|
||||
end
|
||||
|
||||
# Returns the environment of the Rails application,
|
||||
# if this is running in a Rails context.
|
||||
# Returns `nil` if no such environment is defined.
|
||||
#
|
||||
# @return [String, nil]
|
||||
def rails_env
|
||||
return Rails.env.to_s if defined?(Rails.root)
|
||||
return RAILS_ENV.to_s if defined?(RAILS_ENV)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Returns an ActionView::Template* class.
|
||||
# In pre-3.0 versions of Rails, most of these classes
|
||||
# were of the form `ActionView::TemplateFoo`,
|
||||
|
|
|
@ -4,8 +4,8 @@ unless defined?(Sass::RAILS_LOADED)
|
|||
Sass::Plugin.options.merge!(:template_location => Haml::Util.rails_root + '/public/stylesheets/sass',
|
||||
:css_location => Haml::Util.rails_root + '/public/stylesheets',
|
||||
:cache_location => Haml::Util.rails_root + '/tmp/sass-cache',
|
||||
:always_check => RAILS_ENV != "production",
|
||||
:full_exception => RAILS_ENV != "production")
|
||||
:always_check => Haml::Util.rails_env != "production",
|
||||
:full_exception => Haml::Util.rails_env != "production")
|
||||
|
||||
if defined?(ActionDispatch::Callbacks.to_prepare)
|
||||
# Rails >= 3.0.0
|
||||
|
|
Loading…
Add table
Reference in a new issue