getResource method
Import a resource with a certain key
, ignore those already imported
If from
is provided, the handler will try to get a relative path
Otherwise, a absolute path is calculated from root
Implementation
@override
HTSource getResource(String key, {String? from}) {
final normalized = getAbsolutePath(
key: key, dirName: from != null ? path.dirname(from) : root);
if (_cached.containsKey(normalized)) {
return _cached[normalized]!;
} else {
final content = File(normalized).readAsStringSync();
final ext = path.extension(normalized);
final source =
HTSource(content, fullName: normalized, type: checkExtension(ext));
addResource(normalized, source);
return source;
}
}