Documentation
¶
Overview ¶
Package templates defines the Template contract used by the engine to render a request into one of the supported output formats. The concrete templates (classic, repository) implement this interface from their own packages; the registry below is how they advertise themselves to the engine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AllowedFormats = map[string]struct{}{
"svg": {},
"png": {},
"jpeg": {},
"json": {},
}
AllowedFormats is the M1 set of output formats. terminal/markdown templates are NOT adopted in this spec (constitution principle III).
Functions ¶
func CheckAccount ¶
func CheckAccount(meta *config.TemplateMetadata, account string) error
CheckAccount returns nil when account is in meta.Supports, or an InputError otherwise. Templates that need additional shape checks (e.g. "repository" template requires q[repo]) layer their own logic on top of this helper.
func CheckFormat ¶
func CheckFormat(meta *config.TemplateMetadata, format string) error
CheckFormat returns an UnsupportedFormatError when format is not in the supported set declared by metadata. Templates may invoke this from their own Check methods to share the validation.
Types ¶
type PartialContext ¶
type PartialContext struct {
Settings *config.Settings
Inputs map[string]any
Logger *slog.Logger
Data *plugins.Data
Metadata *config.MetadataLoader
}
PartialContext carries the data a partial needs to render its slice of the SVG/Markdown output. Helpers (octicon/twemoji/gemoji) land in M3; the field is nil-safe for M1 callers.
type PartialFunc ¶
type PartialFunc func(ctx context.Context, pc *PartialContext) (string, error)
PartialFunc is the signature each partial (header, activity, repositories, ...) implements. Functions are meant to be idempotent.
type Template ¶
type Template interface {
Name() string
Metadata() *config.TemplateMetadata
FS() fs.FS
Check(q map[string]any, account, format string) error
Run(ctx context.Context, pc *PartialContext) (string, error)
}
Template is the contract every renderer implements. See specs/001-project-foundation/contracts/template-interface.md §1.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package classic implements the M2 "classic" template — the default upstream GitHub-visual-identity SVG layout.
|
Package classic implements the M2 "classic" template — the default upstream GitHub-visual-identity SVG layout. |
|
partials
Package partials hosts the partial functions assembled by the classic template.
|
Package partials hosts the partial functions assembled by the classic template. |
|
Package repository implements the M7 "repository" template — the upstream-equivalent SVG layout focused on a single repository instead of a user profile.
|
Package repository implements the M7 "repository" template — the upstream-equivalent SVG layout focused on a single repository instead of a user profile. |
|
partials
Package partials hosts the repository-template-specific partials the M7 layout needs.
|
Package partials hosts the repository-template-specific partials the M7 layout needs. |