render

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package render parses awf section markers and renders templates with per-project overlays via text/template.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assemble

func Assemble(segs []Segment, plan map[string]SectionPlan) (string, map[string]string)

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 ReferencedVars

func ReferencedVars(src string) []string

ReferencedVars returns the sorted, de-duplicated list of variable names referenced via {{ .vars.X }} patterns in src.

func ReferencesScopes added in v0.6.0

func ReferencesScopes(src string) bool

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

func ReferencesSkills(src string) bool

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

type SectionPlan struct {
	Drop     bool
	HasPart  bool
	PartBody string
	EditPath string
}

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.

type Segment

type Segment struct {
	IsSection bool
	Name      string
	Text      string
}

func ParseSections

func ParseSections(src string) []Segment

ParseSections splits src into ordered literal and section segments. Marker lines are consumed; a section segment's Text is the inner body.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL