template

package
v0.0.0-...-2aea054 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTemplateExists = errors.New("template already exists")
	ErrNoTemplate     = errors.New("template not found")
)

Functions

func GenerateTemplates

func GenerateTemplates(templatesPath string) (map[string]*template.Template, error)

GenerateTemplates produces a map of templates based on a common base layout. It expects the following directory structure

templates/contacts/index.html templates/contacts/new.html templates/names/index.html templates/names/new.html

The base directory name does not matter, but it must not include an underscore as the first character. The base layouts should occur within a directory called _layout in the root templates directory

func Render

func Render(w http.ResponseWriter, status int, templates map[string]*template.Template, ns, name string, data interface{}) error

Render finds the specified template in the map of templates, executes it, and writes it to the writer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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