Skip to main content

Module template

Module template 

Source
Expand description

Templates in tak.toml values, rendered with tera — the same syntax mise uses, so {{ env.HOME }} means the same thing in both files.

tak renders the template itself; no shell is involved, which keeps a subject’s command a plain argv even when it needs a path that only exists at run time. Rendering happens once, before anything is measured, and an undefined variable is an error then rather than a command that fails — or worse, runs against the wrong path — halfway through a long comparison.

In scope for every value:

  • env — tak’s own environment, e.g. {{ env.BENCH_DIR }}
  • bench — the benchmark’s name
  • subject — the subject’s name (self for a single-command benchmark)
  • vars — the subject’s vars tables, merged like env

vars values are templates too, rendered first, so one can build on env.

Functions§

check_str
Check a value’s template compiles, without rendering it. Run over the whole of tak.toml when it is loaded, so a typo fails before any benchmark runs even when the variables it needs are only set later.
env
tak’s environment as a template value. Lossy on non-UTF-8 values, which cannot be written into a TOML string anyway.
render
Render every template in s for benchmark bench.