File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def precompiled_method_return_value_with_haml_xss
3939 end
4040end
4141
42- if defined? ( RAILS_ENV ) && RAILS_ENV == "production"
42+ if Haml :: Util . rails_env == "production"
4343 Haml ::Template . options [ :ugly ] = true
4444end
4545
Original file line number Diff line number Diff line change @@ -146,6 +146,17 @@ def rails_root
146146 return nil
147147 end
148148
149+ # Returns the environment of the Rails application,
150+ # if this is running in a Rails context.
151+ # Returns `nil` if no such environment is defined.
152+ #
153+ # @return [String, nil]
154+ def rails_env
155+ return Rails . env . to_s if defined? ( Rails . root )
156+ return RAILS_ENV . to_s if defined? ( RAILS_ENV )
157+ return nil
158+ end
159+
149160 # Returns an ActionView::Template* class.
150161 # In pre-3.0 versions of Rails, most of these classes
151162 # were of the form `ActionView::TemplateFoo`,
Original file line number Diff line number Diff line change 44 Sass ::Plugin . options . merge! ( :template_location => Haml ::Util . rails_root + '/public/stylesheets/sass' ,
55 :css_location => Haml ::Util . rails_root + '/public/stylesheets' ,
66 :cache_location => Haml ::Util . rails_root + '/tmp/sass-cache' ,
7- :always_check => RAILS_ENV != "production" ,
8- :full_exception => RAILS_ENV != "production" )
7+ :always_check => Haml :: Util . rails_env != "production" ,
8+ :full_exception => Haml :: Util . rails_env != "production" )
99
1010 if defined? ( ActionDispatch ::Callbacks . to_prepare )
1111 # Rails >= 3.0.0
You can’t perform that action at this time.
0 commit comments