result method

StubbleResult result(
  1. StubbleContext context
)

Implementation

StubbleResult result(StubbleContext context) {
  if (!context.callable(_helper)) {
    return StubbleResult(
      pop: true,
      err: StubbleError(
        code: errorHelperUnregistered,
        text: 'Helper "$_helper" is unregistered',
      ),
    );
  }

  final result = StubbleResult();

  try {
    if (_attributes.isEmpty) {
      _attributes.add(context.data);
    }

    result.result = context.call(_helper, _attributes, null);
    result.pop = true;
  } catch (e) {
    result.pop = true;
    result.err = StubbleError(
      text: 'Error in helper function $_helper: ${e.toString()}',
      code: errorCallingHelper,
    );
  }

  return result;
}