getTemplate method

Template getTemplate(
  1. String name
)

Load a template by name with loader and return a Template.

If the template does not exist a TemplateNotFound exception is thrown. If the loader is not specified a StateError is thrown.

Implementation

Template getTemplate(String name) {
  if (loader case var loader?) {
    var loaded = loader.load(this, name, globals: globals);

    if (autoReload) {
      return templates[name] = loaded;
    }

    return templates[name] ??= loaded;
  }

  throw StateError('No loader for this environment specified.');
}