Prevent SelfDrop context mutation across render boundaries#2082
Prevent SelfDrop context mutation across render boundaries#2082
SelfDrop context mutation across render boundaries#2082Conversation
aswamy
left a comment
There was a problem hiding this comment.
Not sure if liquid-spec also allows render tags, but ill update it to capture your test. Thank you for this ❤️
…drop_context_test.rb
ianks
left a comment
There was a problem hiding this comment.
We likely want to undef context as well, which serves as a signal that the drop doesn’t support contextualization
|
Thank you for the review, @ianks! I did consider |
74943a1 to
bc7f1ca
Compare
|
Hi 👋 This looks like a subtle change in policy for the I understand if you've decided this is a positive new feature. It's just that with this change partial templates are less isolated. They are potentially more tightly coupled to their parent templates, which I thought was one of the reasons for introducing And, of course, having arbitrary aliases of |
This PR fixes
SelfDropscoping so aselfassigned in one template preserves its original scope when passed to a rendered template.# template1.liquid {% assign var = 42 %} {% assign s = self %} {% render 'template2', other_self: s %} # template2.liquid {% assign var = 43 %} {{ other_self.var }} => 43 (wrong — should be 42)The fix renames
@contextto@self_contextinSelfDrop, so the drop has a specific reference to its originating context instead of reusing the inheritedcontextthat gets overwritten at thecontext.rblevel on line 220.