templates

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package templates provides email template storage functionality.

Index

Constants

This section is empty.

Variables

View Source
var ErrTemplateNotFound = errors.New("template not found")

ErrTemplateNotFound is returned when a template is not found.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns the default templates file path.

func ExpandVariables

func ExpandVariables(text string, vars map[string]string) (string, []string)

ExpandVariables replaces {{var}} placeholders with provided values. Returns the expanded text and a list of any missing variables.

Types

type FileStore

type FileStore struct {
	// contains filtered or unexported fields
}

FileStore implements TemplateStore using a JSON file.

func NewDefaultFileStore

func NewDefaultFileStore() *FileStore

NewDefaultFileStore creates a FileStore at the default location. The default location is ~/.config/nylas/templates.json

func NewFileStore

func NewFileStore(path string) *FileStore

NewFileStore creates a new FileStore at the specified path.

func (*FileStore) Create

Create creates a new template and returns it with generated ID.

func (*FileStore) Delete

func (f *FileStore) Delete(_ context.Context, id string) error

Delete removes a template by its ID.

func (*FileStore) Get

Get retrieves a template by its ID.

func (*FileStore) IncrementUsage

func (f *FileStore) IncrementUsage(_ context.Context, id string) error

IncrementUsage increments the usage count for a template.

func (*FileStore) List

func (f *FileStore) List(_ context.Context, category string) ([]domain.EmailTemplate, error)

List returns all templates, optionally filtered by category.

func (*FileStore) Path

func (f *FileStore) Path() string

Path returns the path to the templates file.

func (*FileStore) Update

Update updates an existing template.

Jump to

Keyboard shortcuts

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