Skip to main content

Module templates

Module templates 

Source
Expand description

Code Mode instruction and policy templates.

This module provides a simple template engine for generating Code Mode code-mode://instructions and code-mode://policies resources from compiled-in templates. Templates use {{key}} substitution markers.

§Architecture

Each server type crate embeds its own .md template files via include_str!(). The shared template engine here provides:

  • render() — Simple {{key}} → value substitution
  • TemplateContext — Builder for template variables
  • URI constants — Standard resource URIs for auto-generated resources

§Override Mechanism

If an admin defines a resource with the same URI in the TOML config, the admin’s version takes precedence. The server startup code should check for existing resources before registering auto-generated ones.

Structs§

TemplateContext
Template context holding key-value pairs for substitution.

Constants§

INSTRUCTIONS_URI
Standard URI for auto-generated instructions resource.
POLICIES_URI
Standard URI for auto-generated policies resource.

Functions§

conditional
Conditionally include a section based on a boolean.
render
Render a template with the given context.