Package com.hubspot.jinjava.util
Class EagerContextWatcher
java.lang.Object
com.hubspot.jinjava.util.EagerContextWatcher
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic EagerExecutionResultexecuteInChildContext(Function<JinjavaInterpreter, EagerExpressionResolver.EagerExpressionResult> function, JinjavaInterpreter interpreter, EagerContextWatcher.EagerChildContextConfig eagerChildContextConfig) Execute the specified functions within a protected context.
-
Constructor Details
-
EagerContextWatcher
public EagerContextWatcher()
-
-
Method Details
-
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.
-