Install
View as Markdownnpm install @memomori/obol
obol needs Node 22.18 or later. It ships as ES modules with types, and has no dependencies.
Imports #
| Import | Holds |
|---|---|
@memomori/obol |
Template |
@memomori/obol/files |
parseFiles, parseGlob |
@memomori/obol/errors |
TemplateError, ParseError, ExecError |
@memomori/obol/funcs |
isTrue, htmlEscape, jsEscape, urlQueryEscape |
@memomori/obol/parse |
parse, Tree, isEmptyTree |
@memomori/obol/node |
the syntax tree node classes |
@memomori/obol/files reads from disk with node:fs. Every other module runs
in a browser or a worker too.
First template #
import { Template } from '@memomori/obol'
const hello = new Template('hello').parse('Hello, {{.name}}!')
hello.execute({ name: 'Ann' })
That returns Hello, Ann!. Parse once and execute as often as you like: a
parsed template holds no state between runs.