selectTemplate method
Load a template from a list of names.
If the template does not exist a TemplatesNotFound exception is thrown.
Implementation
Template selectTemplate(List<Object?> names) {
if (names.isEmpty) {
throw TemplatesNotFound(
message: 'Tried to select from an empty list of templates.');
}
for (var template in names) {
if (template is Template) {
return template;
}
if (template is String) {
try {
return getTemplate(template);
} on TemplateNotFound {
// ignore
}
}
}
throw TemplatesNotFound(names: names.cast<String>());
}