Skip to main content

Module served

Module served 

Source
Available on crate feature served only.
Expand description

Files a CLI generates into a repository from templates, each template declaring its own target path and mode.

A template declares its target in Jinja’s own syntax, as top-level {%- set -%} exports, instead of a manifest beside it or a mirrored directory tree:

{%- set path = "tasks/toy" -%}
{%- set executable = true -%}
#!/usr/bin/env bash
#MISE tools = { "github:example/toy" = "{{ versions["toy"] }}" }

path is the directory, the repository root when omitted. name is the file name, the template’s own name without its suffix when omitted, so most templates declare one line. executable is the one mode bit git records for a regular file: when omitted, 0644. Trim declarations with {%- … -%} so a shebang stays on line one. Any other export is the template’s own.

Rendering uses surface::environment: undefined names fail, the trailing newline is kept, and ctl-core’s shared fragments are available. Which templates a repository has, and what context they see, stay with the CLI that generates them.

Structs§

ServeError
Why a template could not be rendered or written, naming the template.
Served
A rendered template and the file it becomes, checked and not yet written.

Functions§

render
Render one template with context, and read the target path, name, and mode it declares.