class

Hwaro::Core::Build::SnapshotTemplateLoader

Inherits Crinja::Loader / Reference / Object

Constructors

new(templates : Hash(String, String), template_paths : Hash(String, String), fallback : Crinja::Loader)

templates is keyed by extension-stripped name ("partials/nav"), template_paths maps that name to the source file the snapshot actually loaded ("templates/partials/nav.html"). Both hashes are treated as read-only; load_templates swaps in fresh hashes on reload rather than mutating these.

Source

Instance methods

get_source(env : Crinja, template : String) : Tuple(String, String | Nil)

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.

Source