Sha256: 7783b8481d0d7f993a5f7f1fbe181bd1ef32b8a34c8a11dbc2a037d0c36ed8dc
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true ActionView::Base.class_eval do #FIXME FIXHAML AMCing here because prepending on `render` causes infinite loop when Haml is bundled def render_with_motorhead(options = {}, locals = {}, &block) if (Hash === options) && options.key?(:engine) ext_name = options[:engine][/[^\/]*/] if ext_name.camelize.constantize::Engine.active? controller view_renderer.render(self, options, &block) elsif block capture(&block) end else render_without_motorhead options, locals, &block end end alias_method :render_without_motorhead, :render alias_method :render, :render_with_motorhead end module Motorhead module ActionView module Renderer def render(context, options, &block) if options.key? :engine render_engine(context, options, &block) else super end end def render_engine(context, options, &block) partial_name = options.delete :engine Motorhead::EngineRenderer.new(@lookup_context).render(context, options.merge(partial: partial_name), block) end end end class EngineRenderer < ::ActionView::PartialRenderer def render(context, options, block) super rescue => e ext_name = options[:partial][/[^\/]*/] (ext_name.camelize.constantize::Engine.on_error || Motorhead.config.on_error).call(e) context.capture(&block) end end end ActionView::Renderer.prepend Motorhead::ActionView::Renderer
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
motorhead-0.5.0 | lib/motorhead/action_view.rb |