Skip to content

Commit

Permalink
Merge pull request #952 from RobinDaugherty/fix-erubi-with-rails50
Browse files Browse the repository at this point in the history
Re-fix Erubi on Rails < 5.1
  • Loading branch information
k0kubun committed Aug 18, 2017
2 parents 2e430d4 + 32c466c commit afb9424
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -43,6 +43,5 @@ matrix:
allow_failures:
- rvm: rbx-3
- gemfile: test/gemfiles/Gemfile.rails-edge
- gemfile: test/gemfiles/Gemfile.rails-5.0.x.erubi
fast_finish: true
script: "bundle exec rake submodules test"
10 changes: 9 additions & 1 deletion lib/haml/railtie.rb
Expand Up @@ -26,7 +26,15 @@ class Railtie < ::Rails::Railtie
require "haml/sass_rails_filter"
end

if defined? ActionView::Template::Handlers::ERB::Erubi
# Any object under ActionView::Template will be defined as the root constant with the same
# name if it exists. If Erubi is loaded at all, ActionView::Template::Handlers::ERB::Erubi
# will turn out to be a reference to the ::Erubi module.
# In Rails 4.2, calling const_defined? results in odd exceptions, which seems to be
# solved by looking for ::Erubi first.
# However, in JRuby, the const_defined? finds it anyway, so we must make sure that it's
# not just a reference to ::Erubi.
if defined?(::Erubi) && const_defined?('ActionView::Template::Handlers::ERB::Erubi') &&
ActionView::Template::Handlers::ERB::Erubi != ::Erubi
require "haml/helpers/safe_erubi_template"
Haml::Filters::RailsErb.template_class = Haml::SafeErubiTemplate
else
Expand Down

0 comments on commit afb9424

Please sign in to comment.