Skip to content

Commit

Permalink
Merge pull request #8212 from senny/8197_make_render_in_spacer_templa…
Browse files Browse the repository at this point in the history
…te_work

render every partial with a new `PartialRenderer`.
  • Loading branch information
José Valim committed Nov 19, 2012
2 parents 60790e8 + 1d07d3d commit a1c7eae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions actionpack/CHANGELOG.md
@@ -1,5 +1,11 @@
## Rails 4.0.0 (unreleased) ##

* Render every partial with a new `ActionView::PartialRenderer`. This resolves
issues when rendering nested partials.
Fix #8197

*Yves Senn*

* Introduce `ActionView::Template::Handlers::ERB.escape_whitelist`. This is a list
of mime types where template text is not html escaped by default. It prevents `Jack & Joe`
from rendering as `Jack & Joe` for the whitelisted mime types. The default whitelist
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_view/renderer/renderer.rb
Expand Up @@ -44,11 +44,11 @@ def render_partial(context, options, &block) #:nodoc:
private

def _template_renderer #:nodoc:
@_template_renderer ||= TemplateRenderer.new(@lookup_context)
TemplateRenderer.new(@lookup_context)
end

def _partial_renderer #:nodoc:
@_partial_renderer ||= PartialRenderer.new(@lookup_context)
PartialRenderer.new(@lookup_context)
end
end
end
10 changes: 10 additions & 0 deletions actionpack/test/controller/render_test.rb
Expand Up @@ -646,6 +646,10 @@ def partial_collection_with_spacer
render :partial => "customer", :spacer_template => "partial_only", :collection => [ Customer.new("david"), Customer.new("mary") ]
end

def partial_collection_with_spacer_which_uses_render
render :partial => "customer", :spacer_template => "partial_with_partial", :collection => [ Customer.new("david"), Customer.new("mary") ]
end

def partial_collection_shorthand_with_locals
render :partial => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" }
end
Expand Down Expand Up @@ -1445,6 +1449,12 @@ def test_partial_collection_with_spacer
assert_template :partial => '_customer'
end

def test_partial_collection_with_spacer_which_uses_render
get :partial_collection_with_spacer_which_uses_render
assert_equal "Hello: davidpartial html\npartial with partial\nHello: mary", @response.body
assert_template :partial => '_customer'
end

def test_partial_collection_shorthand_with_locals
get :partial_collection_shorthand_with_locals
assert_equal "Bonjour: davidBonjour: mary", @response.body
Expand Down

0 comments on commit a1c7eae

Please sign in to comment.