Skip to content

Conversation

@emerson-h
Copy link

This fixes #20. Purged and replaced areas from parent layouts should not be evaluated.

@rwz rwz force-pushed the master branch 3 times, most recently from 7a4d140 to afbb627 Compare July 9, 2016 22:46
# 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)
Copy link
Contributor

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

@fractaledmind
Copy link
Contributor

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?

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

Successfully merging this pull request may close these issues.

purge happens after parent templates render

3 participants