Writes body (with optional YAML frontmatter fields) to name under a
source's templates/ directory and commits the change. lengua is
git-backed, so every call to lq_add() for the same name is a new
point in that template's history (see lq_log() / lq_diff()).
Usage
lq_add(
path,
name,
body,
title = NULL,
fields = NULL,
message = "add/update template",
source = NULL
)Arguments
- path
Path to the library (as created by
lq_init()).- name
Relative path/id under the source's
templates/dir, e.g."letters/thank-you.md".- body
The template body, using
{{ variable }}interpolation (minijinja / Jinja2 syntax). See lengua-core's templating guide for the full supported syntax (filters, conditionals, loops, escaping).- title
Optional frontmatter title.
- fields
Optional named character vector of additional frontmatter fields, e.g.
c(tone = "formal").- message
Commit message.
- source
Which source to write to. Required if the library has more than one source.
Examples
store <- withr::local_tempdir()
lq_init(store)
lq_add(store, "hello.md", "Hi {{ name }}!", title = "Hello")