tpl

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package tpl provides a simple template registry and corresponding function for registering and loading templates from that registry.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrAlreadyRegistered is returned when a template with a given
	// key has already been registered.
	ErrAlreadyRegistered = errors.New("template has already been registered")
)

Functions

func Get

func Get(key string) (*template.Template, error)

Get returns the template registered under the given key.

The template must be registered using Register first. If it hasn't been registered successfully before, Get will return an error. Use IsRegistered if you're unsure if the template exists.

func IsRegistered

func IsRegistered(key string) bool

IsRegistered indicates whether a template with the given key has been registered successfully using Register.

func Register

func Register(key string, path string, force bool) (*template.Template, error)

Register parses a template file and registers the instance under the given key. If a template with the key has already registered, Register will return an error unless the registration is forced.

Types

This section is empty.

Jump to

Keyboard shortcuts

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