Permalink
Browse files

Changed ActionView::TemplateHandler#render API method signature to re…

…nder(template, local_assigns = {})
  • Loading branch information...
1 parent 292501c commit 6ebdd0e32b846e99a9885b06fbca2bed58149c7e @josh josh committed Jul 11, 2008
View
@@ -1,5 +1,7 @@
*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

0 comments on commit 6ebdd0e

Please sign in to comment.