templates

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 6 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 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

func RenderTitle(titleTemplate, title string, now time.Time) string

RenderTitle expands a title pattern; cursor tokens drop.

func SlugifyName

func SlugifyName(name string) string

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

type Rendered struct {
	Body         string
	CursorOffset int
}

Rendered is a template body with its tokens expanded; CursorOffset is the rune offset of `{{cursor}}` in the body, or -1 when absent.

func Render

func Render(body, title string, now time.Time) Rendered

Render expands a template body.

func RenderLocale added in v0.5.0

func RenderLocale(body, title string, now time.Time, locale string) Rendered

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 Builtins

func Builtins() []Template

Builtins are the templates the app ships, in its order.

func Merge

func Merge(builtins, custom []Template) []Template

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.

Jump to

Keyboard shortcuts

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