Skip to content

Commit 4e144d8

Browse files
committed
Test that parse errors are ignored when doing nested interpretation
1 parent 09cbfba commit 4e144d8

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/test/java/com/hubspot/jinjava/tree/ExpressionNodeTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,28 @@ public void itEscapesValueWhenContextSet() throws Exception {
236236
assertThat(val("{{ a }}")).isEqualTo("foo < bar");
237237
}
238238

239+
@Test
240+
public void itIgnoresParseErrorsWhenFeatureIsEnabled() {
241+
final JinjavaConfig config = JinjavaConfig
242+
.newBuilder()
243+
.withFeatureConfig(
244+
FeatureConfig
245+
.newBuilder()
246+
.add(JinjavaInterpreter.IGNORE_NESTED_INTERPRETATION_PARSE_ERRORS, c -> true)
247+
.build()
248+
)
249+
.build();
250+
JinjavaInterpreter interpreter = new Jinjava(config).newInterpreter();
251+
Context context = interpreter.getContext();
252+
context.put("myvar", "hello {% if");
253+
context.put("place", "world");
254+
255+
ExpressionNode node = fixture("simplevar");
256+
257+
assertThat(node.render(interpreter).toString()).isEqualTo("hello {% if");
258+
assertThat(interpreter.getErrors()).isEmpty();
259+
}
260+
239261
private String val(String jinja) {
240262
return parse(jinja).render(interpreter).getValue();
241263
}

0 commit comments

Comments
 (0)