loadTemplate method
Implementation
Future<Template> loadTemplate(String templatePath,
{List<String>? ignorePath, List<Pattern>? ignoreRegexp}) async {
var templatePathLC = templatePath.toLowerCase();
if (templatePathLC.endsWith('.json')) {
var data = readFile(templatePath);
var json = dart_convert.json.decode(data);
return Template.fromJson(json);
} else if (templatePathLC.endsWith('.yaml') ||
templatePathLC.endsWith('.yml')) {
var data = readFile(templatePath);
var yaml = loadYaml(data);
return Template.fromJson(yaml);
} else if (templatePathLC.endsWith('.zip')) {
var file = File(templatePath);
var storage = StorageZip.fromCompressed(file.readAsBytesSync());
return await _loadTemplateFromStorage(
storage, templatePath, ignorePath, ignoreRegexp);
} else if (templatePathLC.endsWith('.tar') ||
templatePathLC.endsWith('.tar.gz')) {
var file = File(templatePath);
var storage = StorageTarGzip.fromCompressed(file.readAsBytesSync());
return await _loadTemplateFromStorage(
storage, templatePath, ignorePath, ignoreRegexp);
} else {
var storage = StorageIO.directoryPath(templatePath);
return await _loadTemplateFromStorage(
storage, storage.root.path, ignorePath, ignoreRegexp);
}
}