-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 duplicate caching of some templates #1021
Conversation
The change above makes sure that the `default_content_type` option is always deleted from the options. This in turn makes sure that identical template is cached only once, regardless of whether the explicit `content_type` option is specified or not. Not to mention it also makes sure that the `default_content_type` option is not passed as an engine option to the engine which might complain about it.
@@ -805,7 +805,8 @@ def render(engine, data, options = {}, locals = {}, &block) | |||
layout = engine_options[:layout] if layout.nil? or (layout == true && engine_options[:layout] != false) | |||
layout = @default_layout if layout.nil? or layout == true | |||
layout_options = options.delete(:layout_options) || {} | |||
content_type = options.delete(:content_type) || options.delete(:default_content_type) | |||
content_type = options.delete(:default_content_type) | |||
content_type = options.delete(:content_type) || content_type | |||
layout_engine = options.delete(:layout_engine) || engine | |||
scope = options.delete(:scope) || self | |||
options.delete(:layout) |
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.
How about just calling options.delete(:default_content_type)
here (L811) instead?
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.
I think the fix is fine as it is, as the relevant lines are all together, but whatever rocks your boat. It's zzak's call in the end after all.
Needs a test |
@zzak: I can come up with one, sure. But it won't be anytime soon, if you don't mind. I expect couple of weeks more before I can get back to it... |
@raxoft No rush, if you'd like to work on it let me know! |
Thanks! |
The change above makes sure that the
default_content_type
option is always deleted from the options.This in turn makes sure that identical template is cached only once, regardless of whether the explicit
content_type
option is specified or not.Not to mention it also makes sure that the
default_content_type
option is not passed as an engine option to the engine which might complain about it.