Skip to content

Commit

Permalink
Fix Erubi on JRuby, document the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDaugherty committed Aug 17, 2017
1 parent b26b77a commit 32c466c
Showing 1 changed file with 9 additions and 1 deletion.
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?(::Erubi) && const_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 32c466c

Please sign in to comment.