API
render(view, data)
| 1 | const html = await template.render('info/bla', { title: 'Bla' }); |
view is flexible:
- absolute path (with or without
.tpl.html)
- relative template path (resolved under
src/templates/)
- path including
src/templates/ (relative to project root)
If view cannot be resolved to a file, the string is rendered as an inline template.
renderHtml(html, data)
| 1 | const html = await template.renderHtml('<h1>{{ title }}</h1>', { title: 'Hi' }); |
Events
| Event |
Payload |
When |
template:init |
{ root, paths } |
Discovery begins |
template:discovered |
{ name, file, path } |
Individual template found |
template:ready |
{ count, templates } |
All templates discovered |
template:render:before |
{ view, data, traceId, dataKeys } |
Rendering begins |
template:render:after |
{ view, html, duration, traceId, dataKeys } |
Rendering complete |
template:loaded |
{ name, path } |
Template file loaded |
template:methods:discovered |
{ count, sources } |
Method discovery complete |
template:method:registered |
{ name, source } |
Individual method registered |