Skip to content

Commit

Permalink
Tentatively fix macro function's child scope reconstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmith-hs committed Sep 11, 2024
1 parent f1742bc commit 9636a6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/com/hubspot/jinjava/lib/fn/MacroFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public String getEvaluationResult(
);
} else {
if (!alreadyDeferredInEarlierCall(scopeEntry.getKey(), interpreter)) {
if (
interpreter.getContext().get(scopeEntry.getKey()) == scopeEntry.getValue()
) {
continue; // don't override if it's the same object
}
interpreter.getContext().put(scopeEntry.getKey(), scopeEntry.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public Object doEvaluate(
);
throw new DeferredInvocationResolutionException(tempVarName);
}
if (!eagerExecutionResult.getResult().isFullyResolved()) {
return EagerReconstructionUtils.wrapInChildScope(
eagerExecutionResult.getResult().toString(true),
interpreter
);
}
return eagerExecutionResult.getResult().toString(true);
}

Expand Down

0 comments on commit 9636a6e

Please sign in to comment.