fix: reconstruct current_path when base template defers before blocks#1320
Draft
jasmith-hs wants to merge 1 commit into
Draft
fix: reconstruct current_path when base template defers before blocks#1320jasmith-hs wants to merge 1 commit into
jasmith-hs wants to merge 1 commit into
Conversation
When a base template defers a variable before its block definitions, the
eager first pass produced output without {% set current_path = '...' %},
leaving the second pass without a base-template path reference. This would
break relative path resolution for any base template using includes or
other path-dependent tags.
The pathSetter was only written when resolveBlockStubs() added deferred
tokens (deferred content inside block bodies). It was not written when
the base template itself produced deferred tokens before its blocks
(preserveBlocks = true). Fix: also set pathSetter when preserveBlocks
is true.
Co-Authored-By: Claude Sonnet 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.
Description
When a Jinja template extends a base that defers a variable before its block definitions, the eager first-pass output was missing the
{% set current_path = '...' %}preamble that all other eager extends scenarios include. Without it, the second pass has no base-template path reference, which would break relative path resolution (e.g.,{% include %}calls) inside any such base template.The
pathSetternode — responsible for emitting thecurrent_pathreconstruction — was only written whenresolveBlockStubs()added deferred tokens (i.e., deferred content inside block bodies). It was not written when the base template itself produced deferred tokens before its blocks (preserveBlocks = true). The fix is a one-character condition change: also setpathSetterwhenpreserveBlocksis true.This is the root cause of internal HubL issue https://github.com/HubSpotProductSupport/ProductSupport/issues/146621.
BRAVE
Backwards Compatibility
No API or behavioral change for non-deferred templates. The fix only applies when
preserveBlocksis already true, which only happens in eager mode when the base template itself defers content.Rollout and Rollback Plan
JinjavaInterpreter.javaAutomated Testing
itDefersSetInBaseBeforeBlock— verifies first-pass output now includes{% set current_path = '...' %}itDefersSetInBaseBeforeBlockSecondPass— verifies the second pass renders correctly once the deferred value is resolvedVerification
EagerExtendsTagTestlocally; both new tests passExpect Dependencies to Fail
None expected.
PR description authored by Claude Code
REVIEWERS: Please review both the code changes and the answers above, and validate that they match the expectations for BRAVE