Skip to content

Commit 6fe39df

Browse files
committed
Add feature stub for preventing accidental expressions
1 parent d912e54 commit 6fe39df

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/main/java/com/hubspot/jinjava/tree/output/OutputList.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.hubspot.jinjava.tree.output;
22

3+
import com.hubspot.jinjava.JinjavaConfig;
34
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
45
import com.hubspot.jinjava.interpret.OutputTooBigException;
56
import com.hubspot.jinjava.interpret.TemplateError;
@@ -8,6 +9,8 @@
89
import java.util.List;
910

1011
public class OutputList {
12+
public static final String PREVENT_ACCIDENTAL_EXPRESSIONS =
13+
"PREVENT_ACCIDENTAL_EXPRESSIONS";
1114
private final List<OutputNode> nodes = new LinkedList<>();
1215
private final List<BlockPlaceholderOutputNode> blocks = new LinkedList<>();
1316
private final long maxOutputSize;
@@ -46,6 +49,16 @@ public List<BlockPlaceholderOutputNode> getBlocks() {
4649
}
4750

4851
public String getValue() {
52+
boolean preventAccidentalExpressions = JinjavaInterpreter
53+
.getCurrentMaybe()
54+
.map(JinjavaInterpreter::getConfig)
55+
.map(JinjavaConfig::getFeatures)
56+
.map(
57+
features ->
58+
features.getActivationStrategy(PREVENT_ACCIDENTAL_EXPRESSIONS).isActive(null)
59+
)
60+
.orElse(false);
61+
4962
LengthLimitingStringBuilder val = new LengthLimitingStringBuilder(maxOutputSize);
5063

5164
for (OutputNode node : nodes) {

0 commit comments

Comments
 (0)