build method
Implementation
@override
String build(Context context, ParserResult? result) {
final parsers = _getParsers();
if (parsers.length < 2) {
throw StateError('The list of parsers must contain at least 2 elements');
}
var template = '{{body}}';
final errors = <String>[];
for (var i = 0; i < parsers.length; i++) {
final error = context.allocateLocal();
errors.add(error);
final parser = parsers[i];
final values = {
'error': error,
'p1': parser.build(context, result),
};
final templateParser = render(_templateParser, values);
values.clear();
values.addAll({
'body': templateParser,
});
template = render(template, values);
}
final values = {
'errors': errors.join(', '),
};
final templateFailure = render(_templateFailure, values);
values.clear();
values.addAll({
'body': templateFailure,
});
return render(template, values);
}