lib/action_view/component/base.rb in actionview-component-1.3.3 vs lib/action_view/component/base.rb in actionview-component-1.3.4

- old
+ new

@@ -58,11 +58,10 @@ # returns: # <span title="greeting">Hello, world!</span> # def render_in(view_context, *args, &block) self.class.compile - self.controller = view_context.controller @view_context = view_context @view_renderer ||= view_context.view_renderer @lookup_context ||= view_context.lookup_context @view_flow ||= view_context.view_flow @@ -92,11 +91,16 @@ # We could in theory do this on app boot, at least in production environments. # Right now this just compiles the template the first time the component is rendered. def compile return if @compiled && ActionView::Base.cache_template_loading - class_eval("def call; @output_buffer = ActionView::OutputBuffer.new; #{compiled_template}; end") + class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def call + @output_buffer = ActionView::OutputBuffer.new + #{compiled_template} + end + RUBY @compiled = true end private @@ -149,9 +153,17 @@ "text/html" end end private + + def controller + @controller ||= view_context.controller + end + + def request + @request ||= controller.request + end attr_reader :content, :view_context end end end