Documentation
¶
Overview ¶
Package partials hosts the partial functions assembled by the classic template. Each partial is a templates.PartialFunc that takes a PartialContext and returns the SVG fragment it owns. The contract is documented in specs/002-output-classic-json/contracts/classic-template.md.
Partials follow three rules:
- Empty when nil-safe: missing data (e.g. Data.User == nil) must yield "" without panicking.
- XML safety: dynamic strings flow through classic.EscapeXML.
- Magnitude shortening: integer counts flow through classic.FormatCount.
The classic template owns the call order via partials/_.json.
Index ¶
- Variables
- func BaseActivityCommunity(_ context.Context, _ *templates.PartialContext) (string, error)
- func BaseHeader(_ context.Context, pc *templates.PartialContext) (string, error)
- func BaseRepositories(_ context.Context, pc *templates.PartialContext) (string, error)
- func EscapeXML(s string) string
- func FormatCount(n int64) string
- func Introduction(_ context.Context, pc *templates.PartialContext) (string, error)
- func Lookup(name string) (templates.PartialFunc, bool)
- func Register(name string, fn templates.PartialFunc)
Constants ¶
This section is empty.
Variables ¶
var PluginPartialOrder = []string{
"languages",
"activity",
"achievements",
"repositories",
"isocalendar",
"calendar",
"habits",
"stars",
"people",
"notable",
"contributors",
"reactions",
"projects",
"sponsors",
"sponsorships",
"stargazers",
"traffic",
"topics",
"starlists",
}
PluginPartialOrder defines the M4 plugin partial render order. It mirrors the upstream lowlighter/metrics classic ordering: P1 MVP 5 plugins first, then P2 GraphQL/REST 12 plugins, then P3 chromedp/ heavy 4 plugins. classic.go iterates this slice; slugs whose partial is not yet registered are silently skipped during incremental M4 landing so the build stays green between US1/US2/US3 PRs.
Functions ¶
func BaseActivityCommunity ¶
BaseActivityCommunity renders the outer two-column scaffold that hydrates with activity + community panes once M4 plugins land. M2 emits the section unconditionally so DOM ordering matches upstream.
func BaseHeader ¶
BaseHeader renders the avatar + display name block at the top of the classic SVG. Returns "" when the User payload is absent.
func BaseRepositories ¶
BaseRepositories renders the count / stargazers / forks row. Returns "" when Repositories.Count is zero so the section disappears for fresh accounts.
func EscapeXML ¶
EscapeXML escapes the five XML predefined entities so dynamic strings (login, display name, repository name, etc.) can be safely embedded in the SVG output. The function is intentionally re-entrant: an already-escaped fragment will be re-escaped, which keeps the rule simple — callers must never pre-escape.
func FormatCount ¶
FormatCount renders integer magnitudes with the k/m/b/t short form used by the upstream classic template. It is a thin wrapper around format.Format so callers in this package can stay terse.
func Introduction ¶
Introduction is a stub: the introduction plugin lands in M4. Until then the partial returns "" so the partial dispatch order stays stable.
func Lookup ¶
func Lookup(name string) (templates.PartialFunc, bool)
Lookup returns the registered partial by canonical name. M2 base.* partials are registered during package init(); M4 plugin partials register themselves via Register from their owning plugin package's init(). Returns (nil, false) for unknown names; the classic template treats that as a contract failure for _.json entries and as a silent skip for M4 plugin partials still in flight (US1/US2/US3 land incrementally).
func Register ¶
func Register(name string, fn templates.PartialFunc)
Register adds a PartialFunc under the given name. Subsequent calls with the same name overwrite the previous registration — this is the expected behavior for both the M2 init-based base partial setup and the M4 plugin partial registration path where each plugin package registers itself at process start. Not goroutine-safe; intended to run from init() only.
Types ¶
This section is empty.