evaluateAsync method

FutureOr evaluateAsync(
  1. Evaluator evaluator,
  2. Buffer buffer
)

Evaluates the tag with proper scope management

Implementation

FutureOr<dynamic> evaluateAsync(Evaluator evaluator, Buffer buffer) async {
  evaluator.context.pushScope();

  final innerEvaluator = evaluator.createInnerEvaluator()
    ..context.setRoot(evaluator.context.getRoot());

  var result = await evaluateWithContextAsync(innerEvaluator, buffer);

  // Store the variables from the current scope before popping it
  final currentScopeVariables = innerEvaluator.context.all();
  evaluator.context.popScope();

  // Merge the stored variables back into the previous scope
  evaluator.context.merge(currentScopeVariables);

  return result;
}