Skip to main content

Module loader

Module loader 

Source
Expand description

Template loading with override support.

Responsibilities:

  • Load templates from .ralph/templates/{name}.json first.
  • Fall back to built-in templates if no custom template exists.
  • List all available templates (built-in + custom).
  • Validate templates and return warnings for unknown variables.

Not handled here:

  • Template content validation beyond JSON parsing.
  • Template merging with user options (see merge.rs).

Invariants/assumptions:

  • Custom templates override built-ins with the same name.
  • Template files must have .json extension.
  • Template names are case-sensitive.
  • Variable validation is performed (unknowns produce warnings; strict mode fails).

Structs§

LoadedTemplate
Result of loading a template with context
TemplateInfo
Metadata for a template (used for listing)

Enums§

TemplateError
Error type for template operations
TemplateSource
Source of a loaded template

Functions§

get_template_context
Get the template context for inspection
list_templates
List all available templates (built-in + custom)
load_template
Load a template by name
load_template_with_context
Load a template by name with variable substitution
load_template_with_context_legacy
Load a template by name with variable substitution (legacy, non-strict)
template_exists
Check if a template exists (either custom or built-in)