Class EagerContextWatcher


  • public class EagerContextWatcher
    extends Object
    • Constructor Detail

      • EagerContextWatcher

        public EagerContextWatcher()
    • 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 a set tag that gets prepended to the returned result. The function is 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 context
        interpreter - JinjavaInterpreter to create a child from.
        eagerChildContextConfig - Configuration for evaluation as defined in EagerContextWatcher.EagerChildContextConfig
        Returns:
        An EagerExecutionResult where: result is the string result of function. prefixToPreserveState is either blank or a set tag that preserves the state within the output for a second rendering pass.