templater

package
v0.0.0-...-e682752 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTMLItem

type HTMLItem struct {
	Text string
	// contains filtered or unexported fields
}

HTMLItem is used to inject attributes and text into HTML templates.

func (HTMLItem) AddAttribute

func (item HTMLItem) AddAttribute(key string, value ...string)

AddAttribute creates a key/value pair to represent and format HTML attributes into a string e.g. class="hidden pw-error" Setting a key twice overwrites it. Empty keys are ignored.

func (HTMLItem) Attributes

func (item HTMLItem) Attributes() string

Attributes returns a formatted string of attributes (set by AddAttribute)

type Templater

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

Templater ecapsulates the map to prevent direct access. See RenderTemplate

func New

func New() *Templater

func (*Templater) Load

func (t *Templater) Load(baseGlob, mainGlob string) error

Load loads or reloads template files from the filesystem. Here, baseGlob refers to base templates (usually a wrapper containing headers and such) and mainGlob refers to to the templates that are used to fill the base templates. Globs are of the standard Go format, i.e. templates/*.html

func (*Templater) RenderTemplate

func (t *Templater) RenderTemplate(w io.Writer, name string, base string, data map[string]interface{}) error

RenderTemplate makes sure templates exist and renders them. Don't mix up name and base!

Jump to

Keyboard shortcuts

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