pub struct Frontmatter {Show 14 fields
pub name: Option<String>,
pub description: Option<String>,
pub declarations: Vec<VarDecl>,
pub params: Vec<String>,
pub has_params: bool,
pub allow_unused: bool,
pub type_aliases: HashMap<String, VarType>,
pub imports: Vec<Import>,
pub consts: Vec<VarDecl>,
pub env: Vec<VarDecl>,
pub imported_consts: HashMap<String, Value>,
pub imported_enum_type_keys: Vec<String>,
pub imported_namespace_types: HashMap<String, VarType>,
pub imported_type_params: HashMap<String, (String, String)>,
}Expand description
Parsed YAML frontmatter from a .tmpl.md file.
Fields§
§name: Option<String>Template name (matches SKILL.md name: convention).
description: Option<String>Description of the template’s purpose.
declarations: Vec<VarDecl>List of expected variable declarations (name + type + optional default).
params: Vec<String>Convenience: parameter names only (derived from declarations).
has_params: boolWhether the params: block was present in frontmatter.
allow_unused: boolAllow declared parameters that are never referenced in the body.
Set via allow_unused: true in frontmatter. Useful for
dynamically-loaded templates where params may be conditionally used.
type_aliases: HashMap<String, VarType>Type aliases defined via types: in frontmatter.
Maps alias names (e.g. Priority) to their resolved VarType.
imports: Vec<Import>Import declarations defined via imports: in frontmatter.
consts: Vec<VarDecl>Constants defined via consts: in frontmatter.
env: Vec<VarDecl>Compile-time environment variable declarations.
Provided via CompileOptions::env() at compile time.
imported_consts: HashMap<String, Value>Resolved constants from imports, keyed by stem.NAME.
imported_enum_type_keys: Vec<String>Keys in imported_consts that are enum type namespace dicts
(injected from imported enum type aliases). Used by the bare-enum-access
check to distinguish enum namespaces from struct constants.
imported_namespace_types: HashMap<String, VarType>Type information for imported namespaces, keyed by import stem.
Each entry maps a stem name (e.g. "artist") to a Struct type
whose fields correspond to the imported template’s typed consts.
Used by the type checker to validate field accesses and for-loop
iteration over imported consts.
imported_type_params: HashMap<String, (String, String)>For params whose top-level type is a dotted import reference resolving
to an enum (stem.TypeName), maps the param name to
(import_stem, imported_type_name).
Lets codegen backends (currently the Rust proc-macro) reference the imported, already-generated type directly instead of emitting a duplicate per-template copy. Empty when no such params exist.
Implementations§
Source§impl Frontmatter
impl Frontmatter
Sourcepub fn validate_field_types(&self, segments: &[Segment]) -> Vec<String>
pub fn validate_field_types(&self, segments: &[Segment]) -> Vec<String>
Validate enum-variant names and field accesses across a template body, using the full set of typed declarations derived from this frontmatter.
This is the single source of truth for compile-time field-type checking,
shared by the template! proc-macro and the shared cross-backend test
runners, so their behavior can never drift apart.
Declarations included (all receive full field-level validation):
params:declarations,- typed import stems (imports whose consts carry type info) — this is
what enables
{% for row in stem.LIST_CONST %}{{ row.field }}{% /for %}, - local
consts:, env:variables.
Import stems lacking const type info remain opaque (valid but untyped).
Returns a list of human-readable error strings (empty when valid).
Trait Implementations§
Source§impl Clone for Frontmatter
impl Clone for Frontmatter
Source§fn clone(&self) -> Frontmatter
fn clone(&self) -> Frontmatter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more