Skip to content

Commit 9636a6e

Browse files
committed
Tentatively fix macro function's child scope reconstruction
1 parent f1742bc commit 9636a6e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/main/java/com/hubspot/jinjava/lib/fn/MacroFunction.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ public String getEvaluationResult(
127127
);
128128
} else {
129129
if (!alreadyDeferredInEarlierCall(scopeEntry.getKey(), interpreter)) {
130+
if (
131+
interpreter.getContext().get(scopeEntry.getKey()) == scopeEntry.getValue()
132+
) {
133+
continue; // don't override if it's the same object
134+
}
130135
interpreter.getContext().put(scopeEntry.getKey(), scopeEntry.getValue());
131136
}
132137
}

src/main/java/com/hubspot/jinjava/lib/fn/eager/EagerMacroFunction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ public Object doEvaluate(
126126
);
127127
throw new DeferredInvocationResolutionException(tempVarName);
128128
}
129+
if (!eagerExecutionResult.getResult().isFullyResolved()) {
130+
return EagerReconstructionUtils.wrapInChildScope(
131+
eagerExecutionResult.getResult().toString(true),
132+
interpreter
133+
);
134+
}
129135
return eagerExecutionResult.getResult().toString(true);
130136
}
131137

0 commit comments

Comments
 (0)