Skip to content

Commit 6c62e7e

Browse files
committed
Add test demonstrating issue with modifying and deferring the include
path for an include that has some deferred tokens in it
1 parent 0b610c9 commit 6c62e7e

6 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/test/java/com/hubspot/jinjava/EagerTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,4 +1722,22 @@ public void itHandlesContinueInDeferredForLoopSecondPass() {
17221722
public void itReconstructsFromedMacro() {
17231723
expectedTemplateInterpreter.assertExpectedOutput("reconstructs-fromed-macro/test");
17241724
}
1725+
1726+
@Test
1727+
public void itHandlesModifiedIncludePath() {
1728+
expectedTemplateInterpreter.assertExpectedOutputNonIdempotent(
1729+
"handles-modified-include-path/test"
1730+
);
1731+
}
1732+
1733+
@Test
1734+
public void itHandlesModifiedIncludePathSecondPass() {
1735+
localContext.put("deferred", "resolved");
1736+
expectedTemplateInterpreter.assertExpectedOutput(
1737+
"handles-modified-include-path/test.expected"
1738+
);
1739+
expectedTemplateInterpreter.assertExpectedNonEagerOutput(
1740+
"handles-modified-include-path/test.expected"
1741+
);
1742+
}
17251743
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is include a
2+
{% if deferred %}{% set include_path = './b.jinja' %}{% endif %}
3+
{% include include_path %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is include b
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Before include
2+
This is include a
3+
4+
This is include b
5+
6+
After include
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Before include
2+
{% set __temp_meta_current_path_1035152568__,current_path = current_path,'eager/handles-modified-include-path/a.jinja' %}\
3+
This is include a
4+
{% set include_path = './a.jinja' %}\
5+
{% if deferred %}\
6+
{% set include_path = './b.jinja' %}\
7+
{% endif %}
8+
{% include include_path %}
9+
{% set current_path,__temp_meta_current_path_1035152568__ = __temp_meta_current_path_1035152568__,null %}
10+
After include
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% set include_path = './a.jinja' %}
2+
Before include
3+
{% include include_path %}
4+
After include

0 commit comments

Comments
 (0)