execute method

  1. @override
JinjaValue execute(
  1. Context ctx
)
override

Executes the statement within the given ctx and returns the result as a JinjaValue.

Implementation

@override
JinjaValue execute(Context ctx) {
  JinjaValue? obj;
  final result = _access(ctx, (value) => obj = value);
  final source = obj;
  if (source == null) return result;
  if (result is JinjaFunction) {
    if (isSupplied(result) || !RenderInputs([source]).holdsFinal) {
      return result;
    }
    return JinjaFunction(result.name, (args, kwargs) {
      final inputs = RenderInputs([source, ...args, ...kwargs.values]);
      return inputs.derive(result.handler(args, kwargs));
    });
  }
  return deriveRendered(result, [source]);
}