lib/action_view/component/base.rb in actionview-component-1.2.1 vs lib/action_view/component/base.rb in actionview-component-1.3.0
- old
+ new
@@ -28,11 +28,15 @@
module ActionView
module Component
class Base < ActionView::Base
include ActiveModel::Validations
+ include ActiveSupport::Configurable
+ include ActionController::RequestForgeryProtection
+ delegate :render, to: :view_context
+
# Entrypoint for rendering components. Called by ActionView::Base#render.
#
# view_context: ActionView context from calling view
# args(hash): params to be passed to component being rendered
# block: optional block to be captured within the view context
@@ -56,10 +60,16 @@
# 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
+
@content = view_context.capture(&block) if block_given?
validate!
call
end
@@ -134,9 +144,9 @@
end
end
private
- attr_reader :content
+ attr_reader :content, :view_context
end
end
end