Skip to main content

render_template

Function render_template 

Source
pub fn render_template(
    template: &str,
    db_str: &str,
    bin_cmd: &str,
    delivery: Delivery,
) -> Result<String, CliError>
Expand description

Substitute both template placeholders and keep only the delivery regions this install wants. bin_cmd is the pre-quoted shell form, so the templates carry {{BIN}} unquoted.

One source file describes every delivery, so the variants cannot drift: a <!-- cli --> / <!-- /cli --> (or mcp) pair marks a block only that door’s reader should see, and Both keeps them all. The marker lines themselves are never written. By convention a region opens immediately after the paragraph before it and its content starts with the blank line, so dropping a whole region leaves exactly one blank line behind rather than a hole in the prose.

The regions are checked for well-formedness rather than trusted: an unterminated <!-- mcp --> would silently swallow the rest of the file on the cli variant, and a nested pair would leave the inner close re-opening the outer region, so both are errors and neither can ship as a short skill nobody looked at. The two conditions are the same ones the awk twin in scripts/render-plugin.sh fails on.

Public so the skill’s per-turn budget can be measured on every variant without an install: what this returns is exactly what install writes, and scripts/render-plugin.sh mirrors it for the plugin copy.