class Crinja::Loader::FileSystemLoader
- Crinja::Loader::FileSystemLoader
- Crinja::Loader
- Reference
- Object
Overview
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. The loader takes the path to the templates as string, or if multiple locations are wanted a list of them which is then looked up in the given order.
Defined in:
loader.crConstructors
-
.new(searchpath : String = FileUtils.pwd, encoding = nil, followlinks = false)
The default encoding is
nil
which can be changed by setting the#encoding
parameter to something else. -
.new(searchpaths : Array(String), encoding : String? = nil, followlinks : Bool = false)
The default encoding is
nil
which can be changed by setting the#encoding
parameter to something else.
Instance Method Summary
- #encoding : String?
- #followlinks : Bool
-
#get_source(env : Crinja, template : String) : ::Tuple(String, String)
Get the template source, filename and reload helper for a template.
-
#list_templates
Iterates over all templates.
- #searchpaths : Array(String)
- #to_s(io)
Instance methods inherited from class Crinja::Loader
get_source(env : Crinja, template : String) : ::Tuple(String, String?)
get_source,
list_templates : Iterable(String)
list_templates,
load(env, name)
load
Constructor Detail
The default encoding is nil
which can be changed
by setting the #encoding
parameter to something else.
To follow symbolic links, set the followlinks parameter to true
The default encoding is nil
which can be changed
by setting the #encoding
parameter to something else.
To follow symbolic links, set the followlinks parameter to true
Instance Method Detail
Get the template source, filename and reload helper for a template.
It's passed the environment and template name and has to return a
tuple in the form {source : String, filename : String?}
or raise a
TemplateNotFoundError
if it can't locate the template.
The source part of the returned tuple must be the source of the
template as string. The filename should be the name of the file on
the filesystem if it was loaded from there, otherwise nil
.
The filename is used for the tracebacks if no loader extension is used.
Iterates over all templates. If the loader does not support that
it should raise a TypeError
which is the default behavior.