Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/com/hubspot/jinjava/tree/ExpressionNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public OutputNode render(JinjavaInterpreter interpreter) {
String result = Objects.toString(var, "");

if (interpreter.getConfig().isNestedInterpretationEnabled()) {
if (!StringUtils.equals(result, master.getImage()) && StringUtils.contains(result, "{{")) {
if (!StringUtils.equals(result, master.getImage()) &&
(StringUtils.contains(result, "{{") || StringUtils.contains(result, "{%"))) {
try {
result = interpreter.renderFlat(result);
} catch (Exception e) {
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/com/hubspot/jinjava/tree/ExpressionNodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ public void itRendersWithNestedExpressionInterpretationByDefault() throws Except
assertThat(node.render(noNestedInterpreter).toString()).isEqualTo("hello world");
}

@Test
public void itRendersNestedTags() throws Exception {
final JinjavaConfig config = JinjavaConfig.newBuilder().build();
JinjavaInterpreter jinjava = new Jinjava(config).newInterpreter();
Context context = jinjava.getContext();
context.put("myvar", "hello {% if (true) %}nasty{% endif %}");

ExpressionNode node = fixture("simplevar");
assertThat(node.render(jinjava).toString()).isEqualTo("hello nasty");
}

@Test
public void itAvoidsInfiniteRecursionWhenVarsContainBraceBlocks() throws Exception {
context.put("myvar", "hello {{ place }}");
Expand Down