-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix for #5440 #5480
Fix for #5440 #5480
Conversation
@@ -18,6 +18,14 @@ def render(*args) #:nodoc: | |||
response_body | |||
end | |||
|
|||
def render_to_body(options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this to AC::Rendering or AbsC::Rendering? I would say AbsC::Rendering.
@josevalim ok, so only this line need to be left when I rebased to newest 3-2-stable (I thought I did it, but apparently not ;) ): https://github.com/rails/rails/pull/5480/files#L0R103 Does it look good now? This looks a bit weird and frankly speaking I have a gut feeling that the entire thing could be refactored to be more nice in general (starting with the usage in renderers), but probably this is not safe just before rc. Also, do we need to merge it also with master? |
@@ -100,6 +100,7 @@ def render_to_string(*args, &block) | |||
# :api: plugin | |||
def render_to_body(options = {}) | |||
_process_options(options) | |||
lookup_context.rendered_format = nil if options[:formats] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for nitpicking, but let's move this to _render_template
? This logic only makes sense when rendering a template. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're totally right, I was not sure if render_to_body handles also some other cases that need to also have rendered_format cleared
Yes, let's just move the logic to Overall, I actually don't think this looks weird. Rails 3-2-stable added the possibility of passing :formats along with |
This fixes situation where rendering template to string sets `rendered_format` to the format rendered there. This is ok to have consistent formats rendered in partials, but it breaks on next renders if format is explicitly set or on last render where default format does not necessarily need to be the format of first rendered template.
Ok, I will need to look at the entire code again later. Should I push it also to master? |
@drogus yeah, we should apply this on master |
I've ported to master |
@spastorino thanks! |
This fixes situation where rendering template to string sets
rendered_format
to the format rendered there. This is ok to have consistent formats rendered in partials, but it breaks on next renders if format is explicitly set or on last render where default format does not necessarily need to be the format of first rendered template.cc @josevalim