template

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package template applies date-variable substitution to note templates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(content string, ctx TemplateContext, userVars map[string]string) (string, error)

Apply substitutes all template variables in content string. Returns an error if any date offset is malformed. Known variables (DATE, WEEKNO, TITLE) are resolved from ctx. Unknown variables are resolved from userVars (may be nil). Unresolvable variables are left as-is.

func UnknownVars

func UnknownVars(content string) []string

UnknownVars returns the variable names found in content that are not automatically substituted. The result is ordered by first appearance and deduplicated.

Types

type TemplateContext

type TemplateContext struct {
	Title     string    // note filename stem (may be empty for insert)
	Now       time.Time // zero value >> time.Now() used
	WeekStart string    // "monday" or "sunday"
}

TemplateContext holds the values used to substitute known variables.

Jump to

Keyboard shortcuts

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