Skip to content

fix(eager): reconstruct deferred set tags before block content#1307

Draft
rewaddell wants to merge 1 commit intomasterfrom
rwaddell_hubspot/fix-eager-block-deferred-vars
Draft

fix(eager): reconstruct deferred set tags before block content#1307
rewaddell wants to merge 1 commit intomasterfrom
rwaddell_hubspot/fix-eager-block-deferred-vars

Conversation

@rewaddell
Copy link
Copy Markdown

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.

…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>
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.

1 participant