result method

StubbleResult result(
  1. StubbleContext context
)

Implementation

StubbleResult result(StubbleContext context) {
  if (!context.callable(helper)) {
    return StubbleResult(
      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, context.compile(_body));
    result.pop = true;
  } catch (e) {
    result.err = StubbleError(
      text: 'Helper "$helper" error: ${e.toString()}',
      code: errorCallingHelper,
    );
  }

  return result;
}