Skip to content

Commit

Permalink
Merge pull request #1057 from rdehuyss/master
Browse files Browse the repository at this point in the history
Small refactoring related to #724
  • Loading branch information
boulter committed Apr 24, 2023
2 parents c1e2e0f + 87464de commit 89cd768
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/main/java/com/hubspot/jinjava/Jinjava.java
Expand Up @@ -230,10 +230,10 @@ public RenderResult renderForResult(
JinjavaInterpreter parentInterpreter = JinjavaInterpreter.getCurrent();
if (parentInterpreter != null) {
renderConfig = parentInterpreter.getConfig();
Map<String, Object> bindingsWithParentContext = new HashMap<>(bindings);
if (parentInterpreter.getContext() != null) {
bindingsWithParentContext.putAll(parentInterpreter.getContext());
}
Map<String, Object> bindingsWithParentContext = createBindingsWithParentContext(
bindings,
parentInterpreter.getContext()
);
context =
new Context(
copyGlobalContext(),
Expand Down Expand Up @@ -320,6 +320,17 @@ public void registerExpTest(ExpTest t) {
globalContext.registerExpTest(t);
}

protected Map<String, Object> createBindingsWithParentContext(
Map<String, ?> bindings,
Map<String, ?> bindingsFromParentContext
) {
Map<String, Object> bindingsWithParentContext = new HashMap<>(bindings);
if (bindingsFromParentContext != null) {
bindingsWithParentContext.putAll(bindingsFromParentContext);
}
return bindingsWithParentContext;
}

private Context copyGlobalContext() {
Context context = new Context(null, globalContext);
// copy registered.
Expand Down

0 comments on commit 89cd768

Please sign in to comment.