-
Notifications
You must be signed in to change notification settings - Fork 31
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
Ensure that purged and replaced areas are not evaluated #23
base: master
Are you sure you want to change the base?
Conversation
…ea_contents Skip purged and replaced area contents
7a4d140
to
afbb627
Compare
@@ -189,7 +189,7 @@ def prepend(name, content=nil, &block) | |||
# @param [String] content | |||
# Optionally provide a String of content, instead of a block. A block will take precedence. | |||
def replace(name, content=nil, &block) | |||
content = capture(&block) if block_given? | |||
content = capture(&block) if block_given? && capture_content?(name) |
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.
Correct me if I'm wrong here, but this solution seems like it would only work if the replace
methods content were a block. If the content
were a string, the first half of the conditional would evaluate false
, so this line would not execute, so the call to add_instruction_to_area
would proceed.
It seems to me that what we would actually want is a guard-clause:
def replace(name, content=nil, &block)
return unless capture_content?(name)
content = capture(&block) if block_given?
add_instruction_to_area name, :replace, [content]
end
This needs to be rebased and squashed, and I think the implementation should be evolved a bit (see comment above), but other than that, this seems like a healthy PR, right @rwz? |
This fixes #20. Purged and replaced areas from parent layouts should not be evaluated.