Skip to content

Commit

Permalink
Add feature stub for preventing accidental expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmith-hs committed Oct 23, 2023
1 parent d912e54 commit 6fe39df
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/hubspot/jinjava/tree/output/OutputList.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hubspot.jinjava.tree.output;

import com.hubspot.jinjava.JinjavaConfig;
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
import com.hubspot.jinjava.interpret.OutputTooBigException;
import com.hubspot.jinjava.interpret.TemplateError;
Expand All @@ -8,6 +9,8 @@
import java.util.List;

public class OutputList {
public static final String PREVENT_ACCIDENTAL_EXPRESSIONS =
"PREVENT_ACCIDENTAL_EXPRESSIONS";
private final List<OutputNode> nodes = new LinkedList<>();
private final List<BlockPlaceholderOutputNode> blocks = new LinkedList<>();
private final long maxOutputSize;
Expand Down Expand Up @@ -46,6 +49,16 @@ public List<BlockPlaceholderOutputNode> getBlocks() {
}

public String getValue() {
boolean preventAccidentalExpressions = JinjavaInterpreter
.getCurrentMaybe()
.map(JinjavaInterpreter::getConfig)
.map(JinjavaConfig::getFeatures)
.map(
features ->
features.getActivationStrategy(PREVENT_ACCIDENTAL_EXPRESSIONS).isActive(null)
)
.orElse(false);

LengthLimitingStringBuilder val = new LengthLimitingStringBuilder(maxOutputSize);

for (OutputNode node : nodes) {
Expand Down

0 comments on commit 6fe39df

Please sign in to comment.