Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying a partial format impacts subsequent partials #35222

Closed
tenderlove opened this issue Feb 11, 2019 · 2 comments
Closed

Specifying a partial format impacts subsequent partials #35222

tenderlove opened this issue Feb 11, 2019 · 2 comments

Comments

@tenderlove
Copy link
Member

tenderlove commented Feb 11, 2019

Steps to reproduce

Make an app with one template and three partials. The template should be HTML, two XML partials, and one HTML partial:

[aaron@TC ~/g/view-method-count (master)]$ find app/views/users
app/views/users
app/views/users/index.html.erb
app/views/users/_second.html.erb
app/views/users/_first.xml.erb
app/views/users/_second.xml.erb
[aaron@TC ~/g/view-method-count (master)]$ cat app/views/users/index.html.erb 
Render an XML template:

<%= render partial: "users/first", formats: :xml %>

Render a second, implicit format template (what template should this be?):

<%= render partial: "users/second" %>
[aaron@TC ~/g/view-method-count (master)]$ 

Expected behavior

I would expect the HTML users/second partial to be rendered.

Actual behavior

The XML users/second partial is rendered.

The problem is that rendering the XML format template mutates the lookup context causing "XML" to be the top priority for subsequent renders.

@tenderlove
Copy link
Member Author

This is a dup of #34138

@tenderlove
Copy link
Member Author

I think this PR introduced broken behavior: #6626

tenderlove added a commit that referenced this issue Feb 12, 2019
tenderlove added a commit that referenced this issue Feb 12, 2019
This commit keeps a stack of lookup contexts on the ActionView::Base
instance.  If a format is passed to render, we instantiate a new lookup
context and push it on the stack, that way any child calls to "render"
will use the same format information as the parent.  This also isolates
"sibling" calls to render (multiple calls to render in the same
template).

Fixes #35222 #34138
tenderlove added a commit that referenced this issue Feb 13, 2019
Convert lookup context's to a stack for fixing #35222 and #34138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant