Documentation
¶
Overview ¶
Package templates is the note-template system: the built-ins the app ships, custom templates parsed from `.zennotes/templates/*.md`, and the `{{variable}}` substitution applied when a note is created from one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComposeFile ¶
func ComposeFile(in ComposeInput) string
ComposeFile builds a raw template `.md` from structured fields.
func RenderTitle ¶
RenderTitle expands a title pattern; cursor tokens drop.
func SlugifyName ¶
SlugifyName turns a display name into a safe, lowercase filename stem.
Types ¶
type ComposeInput ¶
type ComposeInput struct {
Name string
Description string
Category string
TitleTemplate string
TargetFolder vault.NoteFolder
TargetSubpath string
BuiltinID string
Body string
}
ComposeInput describes a template file to write.
type Rendered ¶
Rendered is a template body with its tokens expanded; CursorOffset is the rune offset of `{{cursor}}` in the body, or -1 when absent.
type Template ¶
type Template struct {
// ID is `builtin.<name>` for a built-in, `custom:<slug>` for a custom one.
ID string
Name string
Description string
Category string
// Body is markdown with `{{title}}`, `{{date}}`, `{{cursor}}` tokens.
Body string
// TitleTemplate is an optional title pattern.
TitleTemplate string
// TargetFolder is the default destination, never trash.
TargetFolder vault.NoteFolder
TargetSubpath string
Builtin bool
SourcePath string
// BuiltinID marks a custom template that is an edited copy of a
// built-in; it shadows the built-in everywhere.
BuiltinID string
}
Template is a note template, built-in or custom.
func All ¶
func All(custom []vault.CustomTemplateFile, hideBuiltins bool) []Template
All is Merge over the built-ins (unless hidden) and the vault's custom templates.
func Merge ¶
Merge combines built-ins and custom templates into one display list: grouped by category, built-ins (and customized built-ins) before custom within a group, then alphabetical. A custom template carrying builtinId replaces that built-in.
func ParseCustom ¶
func ParseCustom(file vault.CustomTemplateFile) Template
ParseCustom reads a custom template file: optional frontmatter (name, description, category, titleTemplate, targetFolder, targetSubpath, builtinId) plus a body. Never fails.