template

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package template provides template loading and variable substitution for Raven.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(content string, vars *Variables) string

Apply substitutes template variables in the content. Variables use {{name}} syntax. Unknown variables are left as-is. Escaped variables \{{name}} are converted to literal {{name}}.

func Load

func Load(vaultPath, templateSpec, templateDir string) (string, error)

Load loads a template from a file path and enforces template directory policy. Inline template content is not supported.

func ResolveFileRef

func ResolveFileRef(filePath, templateDir string) (string, error)

ResolveFileRef normalizes a template file path and enforces directories.template policy. Bare filenames are resolved under templateDir.

Types

type Variables

type Variables struct {
	// Title is the title passed to rvn new
	Title string
	// Slug is the slugified title
	Slug string
	// Type is the type name
	Type string
	// Date is today's date (YYYY-MM-DD)
	Date string
	// Datetime is the current datetime (YYYY-MM-DDTHH:MM)
	Datetime string
	// Year is the current year
	Year string
	// Month is the current month (2 digit)
	Month string
	// Day is the current day (2 digit)
	Day string
	// Weekday is the day name (Monday, Tuesday, etc.)
	Weekday string
	// Fields are field values from --field flags
	Fields map[string]string
}

Variables holds the available template variables for substitution.

func NewDailyVariables

func NewDailyVariables(date time.Time) *Variables

NewDailyVariables creates Variables for a daily note with a specific date.

func NewVariables

func NewVariables(title, typeName, slug string, fields map[string]string) *Variables

NewVariables creates a Variables struct with the given title, type, and fields. Date/time fields are populated with current time.

Jump to

Keyboard shortcuts

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