提交 1b01ab49 编写于 作者: N Nick Sutterer

remove AV.prepare and move all helper-related logic into the controller. this...

remove AV.prepare and move all helper-related logic into the controller. this decouples the view since it no longer knows about routes internals.
this is a result of an ongoing discussion at https://github.com/rails/rails/pull/6826.
上级 809bdf34
......@@ -49,9 +49,19 @@ def process(*) #:nodoc:
module ClassMethods
def view_context_class
@view_context_class ||= begin
routes = _routes if respond_to?(:_routes)
helpers = _helpers if respond_to?(:_helpers)
ActionView::Base.prepare(routes, helpers)
routes = respond_to?(:_routes) && _routes
helpers = respond_to?(:_helpers) && _helpers
Class.new(ActionView::Base) do
if routes
include routes.url_helpers
include routes.mounted_helpers
end
if helpers
include helpers
end
end
end
end
end
......
......@@ -166,22 +166,6 @@ def cache_template_loading=(value)
def xss_safe? #:nodoc:
true
end
# This method receives routes and helpers from the controller
# and return a subclass ready to be used as view context.
def prepare(routes, helpers) #:nodoc:
Class.new(self) do
if routes
include routes.url_helpers
include routes.mounted_helpers
end
if helpers
include helpers
self.helpers = helpers
end
end
end
end
attr_accessor :view_renderer
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册