templates

package
v0.0.0-...-b4b4fb0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallDefault

func InstallDefault(path string, force bool) error

InstallDefault installs default templates to the specified directory

func InstallDefaultWithOptions

func InstallDefaultWithOptions(opts InstallOptions) error

InstallDefaultWithOptions installs default templates with custom options

Types

type DefaultInputReader

type DefaultInputReader struct{}

DefaultInputReader implements InputReader using standard input

func (*DefaultInputReader) ReadResponse

func (r *DefaultInputReader) ReadResponse() (string, error)

type DefaultTemplateManager

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

DefaultTemplateManager implements the TemplateManager interface

func NewTemplateManager

func NewTemplateManager(templateDir string) (*DefaultTemplateManager, error)

NewTemplateManager creates a new template manager with the given template directory

func (*DefaultTemplateManager) ListTemplates

func (tm *DefaultTemplateManager) ListTemplates() ([]string, error)

ListTemplates returns a list of available templates

func (*DefaultTemplateManager) LoadTemplate

func (tm *DefaultTemplateManager) LoadTemplate(name string) (string, error)

LoadTemplate loads a template from the template directory

func (*DefaultTemplateManager) ProcessTemplate

func (tm *DefaultTemplateManager) ProcessTemplate(name string, data interface{}) (string, error)

ProcessTemplate processes a template with the given data and returns the result

type InputReader

type InputReader interface {
	ReadResponse() (string, error)
}

InputReader defines an interface for reading user input

type InstallOptions

type InstallOptions struct {
	TemplateDir string
	Force       bool
	Reader      InputReader
}

InstallOptions holds configuration for template installation

type TemplateManager

type TemplateManager interface {
	// ProcessTemplate applies the named template to the given data and returns the result.
	// If the template doesn't exist, it returns an error.
	ProcessTemplate(name string, data interface{}) (string, error)

	// LoadTemplate loads the content of a template by name.
	// The template is expected to be a markdown file in the template directory.
	LoadTemplate(name string) (string, error)

	// ListTemplates returns a list of available template names without extensions.
	ListTemplates() ([]string, error)
}

TemplateManager defines the interface for managing note templates. It provides functionality for loading, processing, and listing templates stored in the configured template directory.

Jump to

Keyboard shortcuts

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