Skip to content

Commit 97eca17

Browse files
hs-lsongclaude
andcommitted
fix: Preserve set tags with known RHS values for multi-pass rendering
Enable deferred execution mode to ensure set tags are preserved even when the RHS is fully resolved. This is needed for multi-pass rendering where variables need to remain defined in subsequent render passes. Example: {% set x = name %} with {name: "World"} Before: World (x would be undefined in next pass) After: {% set x = 'World' %}World (x remains defined) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 928f2d5 commit 97eca17

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/main/java/com/hubspot/jinjava/mode/PreserveUndefinedExecutionMode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ public void prepareContext(Context context) {
3737
super.prepareContext(context);
3838
context.setExpressionStrategy(new PreserveUndefinedExpressionStrategy());
3939
context.setDynamicVariableResolver(varName -> DeferredValue.instance());
40+
context.setDeferredExecutionMode(true);
4041
}
4142
}

src/test/java/com/hubspot/jinjava/mode/PreserveUndefinedExecutionModeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ public void itHandlesNestedUndefinedInKnownStructure() {
144144
}
145145

146146
@Test
147-
public void itEvaluatesSetTagWithKnownRHSValue() {
147+
public void itPreservesSetTagWithKnownRHSValue() {
148148
Map<String, Object> context = new HashMap<>();
149149
context.put("name", "World");
150150
String output = render("{% set x = name %}{{ x }}", context);
151-
assertThat(output).isEqualTo("World");
151+
assertThat(output).isEqualTo("{% set x = 'World' %}World");
152152
}
153153

154154
@Test

0 commit comments

Comments
 (0)