render

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 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

Assemble applies the per-section plan to the parsed segments and returns the final template source: literal segments verbatim; each non-dropped section prefixed with its awf:edit pointer, then its part body or the template default. Section markers are consumed here and never written, so they cannot leak. invariant: no-section-marker-leak

func Execute

func Execute(assembled string, data map[string]any) (string, error)

Execute runs text/template over an already-assembled source with the given data under missingkey=zero.

func ReferencedVars

func ReferencedVars(src string) []string

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

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