diff --git a/src/test/java/com/hubspot/jinjava/tree/ExpressionNodeTest.java b/src/test/java/com/hubspot/jinjava/tree/ExpressionNodeTest.java index 12a24c04c..23b482228 100644 --- a/src/test/java/com/hubspot/jinjava/tree/ExpressionNodeTest.java +++ b/src/test/java/com/hubspot/jinjava/tree/ExpressionNodeTest.java @@ -236,6 +236,28 @@ public void itEscapesValueWhenContextSet() throws Exception { assertThat(val("{{ a }}")).isEqualTo("foo < bar"); } + @Test + public void itIgnoresParseErrorsWhenFeatureIsEnabled() { + final JinjavaConfig config = JinjavaConfig + .newBuilder() + .withFeatureConfig( + FeatureConfig + .newBuilder() + .add(JinjavaInterpreter.IGNORE_NESTED_INTERPRETATION_PARSE_ERRORS, c -> true) + .build() + ) + .build(); + JinjavaInterpreter interpreter = new Jinjava(config).newInterpreter(); + Context context = interpreter.getContext(); + context.put("myvar", "hello {% if"); + context.put("place", "world"); + + ExpressionNode node = fixture("simplevar"); + + assertThat(node.render(interpreter).toString()).isEqualTo("hello {% if"); + assertThat(interpreter.getErrors()).isEmpty(); + } + private String val(String jinja) { return parse(jinja).render(interpreter).getValue(); }