File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
main/java/com/hubspot/jinjava/lib/tag
java/com/hubspot/jinjava/lib/tag Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public String getName() {
6767 public String interpret (TagNode tagNode , JinjavaInterpreter interpreter ) {
6868 String macroExpr = "{{" + tagNode .getHelpers ().trim () + "}}" ;
6969
70- try (InterpreterScopeClosable c = interpreter .enterScope ()) {
70+ try (InterpreterScopeClosable c = interpreter .enterNonStackingScope ()) {
7171 LinkedHashMap <String , Object > args = new LinkedHashMap <>();
7272 MacroFunction caller = new MacroFunction (
7373 tagNode .getChildren (),
Original file line number Diff line number Diff line change 44
55import com .google .common .io .Resources ;
66import com .hubspot .jinjava .BaseInterpretingTest ;
7+ import com .hubspot .jinjava .Jinjava ;
8+ import com .hubspot .jinjava .JinjavaConfig ;
9+ import com .hubspot .jinjava .interpret .JinjavaInterpreter ;
710import java .io .IOException ;
811import java .nio .charset .StandardCharsets ;
912import org .jsoup .Jsoup ;
@@ -20,6 +23,28 @@ public void testSimpleFn() {
2023 .isEqualTo ("This is a simple dialog rendered by using a macro and a call block." );
2124 }
2225
26+ @ Test
27+ public void itDoesNotDoubleCountCallTagTowardsDepth () throws IOException {
28+ interpreter =
29+ new Jinjava (
30+ JinjavaConfig
31+ .newBuilder ()
32+ .withEnableRecursiveMacroCalls (true )
33+ .withMaxMacroRecursionDepth (6 ) // There are 3 call tags, but a total of 6 "macro" calls happening in this file as each call to `caller()` counts too
34+ .build ()
35+ )
36+ .newInterpreter ();
37+ JinjavaInterpreter .pushCurrent (interpreter );
38+
39+ try {
40+ String template = fixture ("multiple" );
41+ interpreter .render (template );
42+ assertThat (interpreter .getErrorsCopy ()).isEmpty ();
43+ } finally {
44+ JinjavaInterpreter .popCurrent ();
45+ }
46+ }
47+
2348 private String fixture (String name ) {
2449 try {
2550 return Resources .toString (
Original file line number Diff line number Diff line change 1+ {% macro test 1() %} 1{{ caller() }}{% endmacro %}
2+ {% macro test 2() %} 2{{ caller() }}{% endmacro %}
3+ {% macro test 3() %} 3{{ caller() }}{% endmacro %}
4+ {% call test 1() %}{% call test 2() %}{% call test 3() %}{% endcall %}{% endcall %}{% endcall %}
You can’t perform that action at this time.
0 commit comments