tmpl

package
v0.0.0-...-a7a3610 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustRenderOnce

func MustRenderOnce(contents string, data interface{}) string

MustRenderOnce performs a RenderOnce and will exit the program when an error occurs.

func Register

func Register(name, contents string) error

Register will compile and register a template using the string given and store the compiled template in the map.

func RegisterFile

func RegisterFile(name, filename string) error

RegisterFile will compile and register a template using the contents of a file and storing by name in the compiled map.

func RenderOnce

func RenderOnce(contents string, data interface{}) (string, error)

RenderOnce bypasses storing the saved templates. Tihs should only be used if the template is only ever going to be compiled and rendered _one time_.

func Unregister

func Unregister(name string)

Unregister removes a previously compiled template, normally only used for testing purposes but in cases a template is, for some reason, miscompiled (although longer term solutions should be much more preferred than unregistering)

Types

type InvalidDataError

type InvalidDataError string

InvalidDataError represents that a data value was provided of an unexpected type.

func (InvalidDataError) Error

func (i InvalidDataError) Error() string

Error returns an error message that represents the type of data that was received and what is expected.

type Renderer

type Renderer interface {
	Render(interface{}) (string, error)
	RenderTo(io.Writer, interface{}) error
}

Renderer is an interface defining the necessary methods for interacting with a templtae engine.

func Template

func Template(name string) (Renderer, error)

Template returns the Renderer associated with a registered template, if any.

Jump to

Keyboard shortcuts

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