jaelTemplatePreload function

Future<void> jaelTemplatePreload(
  1. Directory viewsDirectory,
  2. Map<String, Document> cache, {
  3. String fileExtension = '.jael',
  4. bool asDSX = false,
  5. Iterable<Patcher> patch = const [],
})

Preload all of Jael templates into a cache

To apply additional transforms to parsed documents, provide a set of patch functions.

Implementation

Future<void> jaelTemplatePreload(
    Directory viewsDirectory, Map<String, Document> cache,
    {String fileExtension = '.jael',
    bool asDSX = false,
    Iterable<Patcher> patch = const []}) async {
  await viewsDirectory.list(recursive: true).forEach((f) async {
    if (f.basename.endsWith(fileExtension)) {
      var name = f.basename.split(".");
      if (name.length > 1) {
        //print("View: ${name[0]}");
        Document? processed = await _loadViewTemplate(viewsDirectory, name[0]);
        if (processed != null) {
          cache[name[0]] = processed;
        }
      }
    }
  });
}