template

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTemplateFileName

func ParseTemplateFileName(fileName string, opts config.FileOpts) (t time.Time, ok bool)

ParseTemplateFileName extracts a time.Time from a file name and returns an additional bool indicating if name corresponds to a valid template file name

Types

type MonthArchiveTemplate

type MonthArchiveTemplate struct {
	*Template
}

MonthArchiveTemplate contains the structure of a month archive

func NewMonthArchiveTemplate

func NewMonthArchiveTemplate(opts config.Opts, date time.Time) *MonthArchiveTemplate

NewMonthArchiveTemplate constructs a new MonthArchiveTemplate

func (*MonthArchiveTemplate) ArchiveSectionContents

func (t *MonthArchiveTemplate) ArchiveSectionContents(src *Template, sectionName string) error

ArchiveSectionContents concatenates the contents of the specified section from a source template and appends to the contents of the receiver's section with a header derived from the source template's date

func (*MonthArchiveTemplate) GetFilePath

func (t *MonthArchiveTemplate) GetFilePath() string

GetFilePath generates a full path for a file based on the template date

func (*MonthArchiveTemplate) Merge

Merge merges a source MonthArchiveTemplate into the receiver This is a convenience function that iterates and copies all sections in the receiver

func (*MonthArchiveTemplate) Write

func (t *MonthArchiveTemplate) Write(w io.Writer) error

Write writes the template This function is needed to ensure the string() method of the MonthArchiveTemplate is called

type Template

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

Template contains the structure of a note

func NewTemplate

func NewTemplate(opts config.Opts, date time.Time) *Template

NewTemplate constructs a new Template

func (*Template) CopySectionContents

func (t *Template) CopySectionContents(src sectionGettable, sectionName string) error

CopySectionContents copies the contents of the specified section from a source template by appending to the contents of the receiver's section

func (*Template) DeleteSectionContents

func (t *Template) DeleteSectionContents(sectionName string) error

DeleteSectionContents deletes the contents of a specified section

func (*Template) GetDate

func (t *Template) GetDate() time.Time

GetDate returns the template's date

func (*Template) GetFileCursorLine

func (t *Template) GetFileCursorLine() int

GetFileCursorLine returns the line at which to place the cursor when opening the template

func (*Template) GetFilePath

func (t *Template) GetFilePath() string

GetFilePath generates a full path for a file based on the template date

func (*Template) Load

func (t *Template) Load(r io.Reader) error

Load populates a Template from the contents of a reader

func (*Template) Write

func (t *Template) Write(w io.Writer) error

Write writes the template

Directories

Path Synopsis
Package templatetest provides utilities for template testing
Package templatetest provides utilities for template testing

Jump to

Keyboard shortcuts

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