| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,8 @@ | |||
| 15 | 15 | **********************************************************************/ | |
| 16 | 16 | package com.hubspot.jinjava.lib.tag; | |
| 17 | 17 | ||
| 18 | + import static com.hubspot.jinjava.util.Logging.ENGINE_LOG; | ||
| 19 | + | ||
| 18 | 20 | import com.google.common.collect.Lists; | |
| 19 | 21 | import com.hubspot.jinjava.doc.annotations.JinjavaDoc; | |
| 20 | 22 | import com.hubspot.jinjava.doc.annotations.JinjavaHasCodeBody; | |
@@ -165,6 +167,7 @@ public String renderForCollection( | |||
| 165 | 167 | Object collection | |
| 166 | 168 | ) { | |
| 167 | 169 | ForLoop loop = ObjectIterator.getLoop(collection); | |
| 170 | + int loopCount = 0; | ||
| 168 | 171 | ||
| 169 | 172 | try (InterpreterScopeClosable c = interpreter.enterScope()) { | |
| 170 | 173 | if (interpreter.isValidationMode() && !loop.hasNext()) { | |
@@ -178,6 +181,7 @@ public String renderForCollection( | |||
| 178 | 181 | interpreter.getConfig().getMaxOutputSize() | |
| 179 | 182 | ); | |
| 180 | 183 | while (loop.hasNext()) { | |
| 184 | + ++loopCount; | ||
| 181 | 185 | Object val; | |
| 182 | 186 | try { | |
| 183 | 187 | val = interpreter.wrap(loop.next()); | |
@@ -274,6 +278,8 @@ public String renderForCollection( | |||
| 274 | 278 | } | |
| 275 | 279 | } | |
| 276 | 280 | return checkLoopVariable(interpreter, buff); | |
| 281 | + } finally { | ||
| 282 | + ENGINE_LOG.error("Loop count {}", loopCount); | ||
| 277 | 283 | } | |
| 278 | 284 | } | |
| 279 | 285 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ public String eagerInterpret( | |||
| 41 | 41 | InterpretException e | |
| 42 | 42 | ) { | |
| 43 | 43 | interpreter.getContext().checkNumberOfDeferredTokens(); | |
| 44 | - try (InterpreterScopeClosable c = interpreter.enterScope()) { | ||
| 44 | + try (InterpreterScopeClosable c = interpreter.enterNonStackingScope()) { | ||
| 45 | 45 | MacroFunction caller = new MacroFunction( | |
| 46 | 46 | tagNode.getChildren(), | |
| 47 | 47 | "caller", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,6 +77,20 @@ public void itReconstructsForAliasedName() { | |||
| 77 | 77 | .isEqualTo(String.format(codeFormat, fullName)); | |
| 78 | 78 | } | |
| 79 | 79 | ||
| 80 | + @Test | ||
| 81 | + public void itResolvesFromSet() { | ||
| 82 | + String template = | ||
| 83 | + "{% macro foo(foobar, other) %}" + | ||
| 84 | + " {% do foobar.update({'a': 'b'} ) %} " + | ||
| 85 | + " {{ foobar }} and {{ other }}" + | ||
| 86 | + "{% endmacro %}" + | ||
| 87 | + "{% set bar = {} %}" + | ||
| 88 | + "{% call foo(bar, deferred) %} {% endcall %}" + | ||
| 89 | + "{{ bar }}"; | ||
| 90 | + String firstPass = interpreter.render(template); | ||
| 91 | + assertThat(firstPass).isEqualTo(template); | ||
| 92 | + } | ||
| 93 | + | ||
| 80 | 94 | @Test | |
| 81 | 95 | public void itReconstructsImageWithNamedParams() { | |
| 82 | 96 | String name = "foo"; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments