FileSystemLoader class

Loads templates from the file system.

This loader can find templates in folders on the file system and is the preferred way to load them:

var loader = FileSystemLoader(
  path: 'templates',
  extensions: ['html', 'xml'],
);

or:

var loader = FileSystemLoader(
  paths: ['overrides/templates', 'default/templates'],
  extensions: ['html', 'xml'],
);

To follow symbolic links, set the followLinks parameter to true:

var loader = FileSystemLoader(path: 'path', followLinks: true);
Inheritance

Constructors

FileSystemLoader({List<String> paths = const <String>['templates'], bool recursive = true, bool followLinks = true, Set<String> extensions = const <String>{'html'}, Encoding encoding = utf8})
Loads templates from the file system.

Properties

encoding → Encoding
final
extensions → Set<String>
final
final
hashCode → int
The hash code for this object.
no setterinherited
hasSourceAccess → bool
Returns true if this loader can provide access to the source.
no setterinherited
paths → List<String>
final
recursive → bool
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

findFile(String path) → File?
getSource(String path) → String
Get template source from file.
override
isTemplate(String template) → bool
listTemplates() → List<String>
Iterates over all templates.
override
load(Environment environment, String path, {Map<String, Object?>? globals}) → Template
Loads a template to the environment template cache.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited