Skip to content

Commit

Permalink
Test that parse errors are ignored when doing nested interpretation
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmith-hs committed Sep 3, 2024
1 parent 958c43a commit 6a37046
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/test/java/com/hubspot/jinjava/tree/ExpressionNodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 6a37046

Please sign in to comment.