Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-fix Erubi on Rails < 5.1 #952

Merged
merged 3 commits into from Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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