Package com.hubspot.jinjava.util
Class EagerContextWatcher
- java.lang.Object
-
- com.hubspot.jinjava.util.EagerContextWatcher
-
@Beta public class EagerContextWatcher extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEagerContextWatcher.EagerChildContextConfig
-
Constructor Summary
Constructors Constructor Description EagerContextWatcher()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static EagerExecutionResultexecuteInChildContext(Function<JinjavaInterpreter,EagerExpressionResolver.EagerExpressionResult> function, JinjavaInterpreter interpreter, EagerContextWatcher.EagerChildContextConfig eagerChildContextConfig)Execute the specified functions within a protected context.
-
-
-
Method Detail
-
executeInChildContext
public static EagerExecutionResult executeInChildContext(Function<JinjavaInterpreter,EagerExpressionResolver.EagerExpressionResult> function, JinjavaInterpreter interpreter, EagerContextWatcher.EagerChildContextConfig eagerChildContextConfig)
Execute the specified functions within a protected context. Additionally, if the execution causes existing values on the context to become deferred, then their previous values will wrapped in asettag that gets prepended to the returned result. Thefunctionis run in deferredExecutionMode=true, where the context needs to be protected from having values updated or set, such as when evaluating both the positive and negative nodes in an if statement.- Parameters:
function- Function to run within a "protected" child contextinterpreter- JinjavaInterpreter to create a child from.eagerChildContextConfig- Configuration for evaluation as defined inEagerContextWatcher.EagerChildContextConfig- Returns:
- An
EagerExecutionResultwhere:resultis the string result offunction.prefixToPreserveStateis either blank or asettag that preserves the state within the output for a second rendering pass.
-
-