partials

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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:

  1. Empty when nil-safe: missing data (e.g. Data.User == nil) must yield "" without panicking.
  2. XML safety: dynamic strings flow through classic.EscapeXML.
  3. Magnitude shortening: integer counts flow through classic.FormatCount.

The classic template owns the call order via partials/_.json.

Index

Constants

This section is empty.

Variables

View Source
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

func BaseActivityCommunity(_ context.Context, _ *templates.PartialContext) (string, error)

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

func BaseHeader(_ context.Context, pc *templates.PartialContext) (string, error)

BaseHeader renders the avatar + display name block at the top of the classic SVG. Returns "" when the User payload is absent.

func BaseRepositories

func BaseRepositories(_ context.Context, pc *templates.PartialContext) (string, error)

BaseRepositories renders the count / stargazers / forks row. Returns "" when Repositories.Count is zero so the section disappears for fresh accounts.

func EscapeXML

func EscapeXML(s string) string

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

func FormatCount(n int64) string

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

func Introduction(_ context.Context, pc *templates.PartialContext) (string, error)

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.

Jump to

Keyboard shortcuts

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