fix(eager): reconstruct deferred set tags before block content#1307
Draft
fix(eager): reconstruct deferred set tags before block content#1307
Conversation
…ends templates
When a parent template sets a deferred variable after a block placeholder
(e.g. `{% set first_name = deferred %}`), child block content using that
variable would fail to resolve on the second render pass. This happened
because the `{% set %}` tag appeared after the block content in the output,
so the second pass evaluated `{{ first_name }}` before it was defined.
The fix adds `reconstructDeferredVariablesBeforeBlock()` to
`resolveBlockStubs()`, which identifies deferred variables used (but not
set) within a block, finds prior DeferredTokens that define those
variables, and prepends their set tag images before the block content.
Fixes HubSpotProductSupport/ProductSupport#133376
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a parent template sets a deferred variable after a block placeholder (e.g.
{% set first_name = deferred %}), child block content using that variable would fail to resolve on the second render pass. This happened because the{% set %}tag appeared after the block content in the output, so the second pass evaluated{{ first_name }}before it was defined.The fix adds
reconstructDeferredVariablesBeforeBlock()toresolveBlockStubs(), which identifies deferred variables used (but not set) within a block, finds prior DeferredTokens that define those variables, and prepends their set tag images before the block content.