templates

package
v0.0.0-...-82bc1ab Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedTemplate = errors.New("template specified has unsupported extension")

ErrUnsupportedTemplate indicates that the file type of the specified template is not supported

Functions

This section is empty.

Types

type Dir

type Dir struct {
	*file.Dir
	Templates map[string]Template
}

Dir is a directory containing Template files

func NewDir

func NewDir(path string) (d *Dir, err error)

NewDir creates a Dir from the specified path, recursively

func (*Dir) Get

func (d *Dir) Get(name string) (tmpl Template, err error)

Get retrieves a specific template by name

func (*Dir) Sub

func (d *Dir) Sub(name string) (next *Dir, err error)

Sub returns a subdirectory of the current directory

func (*Dir) Update

func (d *Dir) Update(force bool) (err error)

Update rereads the entire Dir from disk

type HTML

type HTML struct {
	file.File
	// contains filtered or unexported fields
}

HTML is a standard html/template

func NewHTML

func NewHTML(path string) (h *HTML, err error)

NewHTML creates a new HTML template from the file at the specified path

func (*HTML) Execute

func (h *HTML) Execute(out io.Writer, data interface{}) error

Execute generates an HTML document from the template and the provided data

func (*HTML) Update

func (h *HTML) Update() error

Update re-reads the template from disk if it has changed

type Template

type Template interface {
	// Execute generates an HTML document from the template
	Execute(out io.Writer, data interface{}) error
	// IsNewer checks if this template has been modified after a specific time
	IsNewer(other *file.File) bool
	// Update re-reads the template from disk
	Update() error
}

Template represents any supported template type for content

func NewTemplate

func NewTemplate(path string) (Template, error)

NewTemplate creates a new Template from a file on disk

type Tree

type Tree struct {
	Root *Dir
}

Tree contains the full tree of Templates for this site

func Load

func Load(path string) (t *Tree, err error)

Load reads the template Tree from disk

func (*Tree) Sub

func (t *Tree) Sub(path string) (dir *Dir, err error)

Sub retrieves a subdirectory by name

func (*Tree) Update

func (t *Tree) Update(force bool) error

Update rereads the entire Tree

Jump to

Keyboard shortcuts

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