Skip to content

Commit

Permalink
Add test that meta context variables are not overridden when importing
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmith-hs committed May 16, 2024
1 parent a77c4e7 commit d49c704
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/java/com/hubspot/jinjava/EagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1572,4 +1572,21 @@ public void itReconstructsBlockPathWhenDeferredNestedSecondPass() {
"reconstructs-block-path-when-deferred-nested/test.expected"
);
}

@Test
public void itKeepsMetaContextVariablesThroughImport() {
setupWithExecutionMode(
new EagerExecutionMode() {
@Override
public void prepareContext(Context context) {
super.prepareContext(context);
context.getMetaContextVariables().add("meta");
}
}
);
interpreter.getContext().put("meta", new ArrayList<>());
expectedTemplateInterpreter.assertExpectedOutput(
"keeps-meta-context-variables-through-import/test"
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I am a boring import
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% set list = deferred %}

{% set meta = ['overridden'] %}{% do list.append(meta) %}
{{ list }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% set meta = ['overridden'] %}
{% set list = deferred %}
{% import '../../eager/keeps-meta-context-variables-through-import/import-target.jinja' %}
{% do list.append(meta) %}
{{ list }}

0 comments on commit d49c704

Please sign in to comment.