提交 6ebdd0e3 编写于 作者: J Joshua Peek

Changed ActionView::TemplateHandler#render API method signature to...

Changed ActionView::TemplateHandler#render API method signature to render(template, local_assigns = {})
上级 292501c7
*Edge*
* Changed ActionView::TemplateHandler#render API method signature to render(template, local_assigns = {}) [Josh Peek]
* Changed PrototypeHelper#submit_to_remote to PrototypeHelper#button_to_remote to stay consistent with link_to_remote (submit_to_remote still works as an alias) #8994 [clemens]
* Add :recursive option to javascript_include_tag and stylesheet_link_tag to be used along with :all. #480 [Damian Janowski]
......
......@@ -332,8 +332,8 @@ def assign_variables_from_controller
@assigns.each { |key, value| instance_variable_set("@#{key}", value) }
end
def execute(template)
send(template.method, template.locals) do |*names|
def execute(template, local_assigns = {})
send(template.method, local_assigns) do |*names|
instance_variable_get "@content_for_#{names.first || 'layout'}"
end
end
......
......@@ -8,7 +8,7 @@ module Renderable
def render
prepare!
@handler.render(self)
@handler.render(self, @locals)
end
def method
......
......@@ -8,7 +8,7 @@ def initialize(view)
@view = view
end
def render(template)
def render(template, local_assigns = {})
end
def compile(template)
......
......@@ -14,8 +14,8 @@ def compilable?
end
end
def render(template)
@view.send(:execute, template)
def render(template, local_assigns = {})
@view.send(:execute, template, local_assigns)
end
# Compile and evaluate the template's code
......
......@@ -34,8 +34,8 @@ class MultipleExtensions < LayoutTest
class MabView < ActionView::TemplateHandler
def initialize(view)
end
def render(template)
def render(template, local_assigns)
template.source
end
end
......
......@@ -95,8 +95,8 @@ def test_render_fallbacks_to_erb_for_unknown_types
end
class CustomHandler < ActionView::TemplateHandler
def render(template)
[template.source, template.locals].inspect
def render(template, local_assigns)
[template.source, local_assigns].inspect
end
end
......@@ -115,18 +115,17 @@ class CompilableCustomHandler < ActionView::TemplateHandler
def compile(template)
"@output_buffer = ''\n" +
"@output_buffer << 'locals: #{template.locals.inspect}, '\n" +
"@output_buffer << 'source: #{template.source.inspect}'\n"
end
end
def test_render_inline_with_compilable_custom_type
ActionView::Template.register_template_handler :foo, CompilableCustomHandler
assert_equal 'locals: {}, source: "Hello, World!"', @view.render(:inline => "Hello, World!", :type => :foo)
assert_equal 'source: "Hello, World!"', @view.render(:inline => "Hello, World!", :type => :foo)
end
def test_render_inline_with_locals_and_compilable_custom_type
ActionView::Template.register_template_handler :foo, CompilableCustomHandler
assert_equal 'locals: {:name=>"Josh"}, source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo)
assert_equal 'source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo)
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册