Documentation
¶
Overview ¶
Package render parses awf section markers and renders templates with per-project overlays via text/template.
Index ¶
- func Assemble(segs []Segment, plan map[string]SectionPlan) (string, map[string]string)
- func Execute(assembled string, data map[string]any, parts map[string]string, name string) (string, error)
- func ExpandIncludes(src string, partialFS fs.FS) (string, error)
- func ReferencedVars(src string) []string
- func ReferencesScopePlaceholder(body string) bool
- func ReferencesScopes(src string) bool
- func ReferencesSkills(src string) bool
- type SectionPlan
- type Segment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assemble ¶
Assemble applies the per-section plan to the parsed segments and returns the template skeleton plus a sentinel→raw-body map. Literal segments pass through verbatim; each non-dropped section is prefixed with its awf:edit pointer, then either a sentinel standing in for its part body (restored after Execute) or the template default. Section markers are consumed here and never written. invariant: no-section-marker-leak
func Execute ¶
func Execute(assembled string, data map[string]any, parts map[string]string, name string) (string, error)
Execute runs text/template over the awf-owned skeleton (part bodies stood in by sentinels) under missingkey=zero, then restores each raw part body verbatim — so a convention part is never parsed or executed as a template. name labels parse and execute errors with the target rather than a hardcoded literal. invariant: parts-raw
func ExpandIncludes ¶ added in v0.6.2
ExpandIncludes replaces each `<!-- awf:include NAME -->` directive line in src with the verbatim body of the awf-owned partial `partials/NAME.md`, read from partialFS. Expansion runs before section parsing, so spliced content is thereafter indistinguishable from inline template text. Three conditions are hard errors: a missing partial, a partial that itself contains an awf:include (nested includes are unsupported), and a partial that contains an awf:section/awf:end marker (overlay across a splice boundary is unspecified). invariant: include-splice invariant: include-missing-fails invariant: include-no-nested invariant: include-no-sections
func ReferencedVars ¶
ReferencedVars returns the sorted, de-duplicated list of variable names referenced via {{ .vars.X }} patterns in src.
func ReferencesScopePlaceholder ¶ added in v0.8.0
ReferencesScopePlaceholder reports whether a raw convention-part body uses a {{=awf:commitScope*}} sandbox placeholder (ADR-0057), so the artifact folds the resolved scope list into its config hash and reflags on a scopes edit.
func ReferencesScopes ¶ added in v0.6.0
ReferencesScopes reports whether src reads the resolved commit-scope render context (any {{ … .commitScopes … }} action) — such templates fold the resolved scope list into their config hash (ADR-0051, mirroring ADR-0046's ReferencesSkills).
func ReferencesSkills ¶ added in v0.6.0
ReferencesSkills reports whether src reads the enabled-skills render context (any {{ … .skills… }} action) — such templates fold the effective skills set into their config hash (ADR-0046).
Types ¶
type SectionPlan ¶
SectionPlan is the project layer's per-section resolution handed to Assemble. Exactly one of Drop / HasPart / (neither) holds: Drop omits the section, HasPart substitutes PartBody, neither renders the template default. EditPath is the project-relative convention part path named by the awf:edit pointer.