pages

package module
v0.0.0-...-66c9da5 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 10 Imported by: 0

README

pages

A package for simple nested html/templates. It is an extension to layouts that trades flexibility for ease of use. View the documentation.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultGroup = &Group{
	Dir:        "pages",
	LayoutsDir: "layouts",
}

Functions

func Handler

func Handler(name string, data interface{}) http.Handler

Handler returns an http.Handler which serves the named static page.

func SetPrecache

func SetPrecache(precache bool)

SetPrecache enables precaching of templates for production usage. By default, precache is disabled to ease website development.

Types

type Group

type Group struct {
	Dir        string
	LayoutsDir string
	Funcs      template.FuncMap
	// contains filtered or unexported fields
}

TODO: Is there a reason to add mutexes for safe concurrency? Everything should be called at init, in the same function, but...hmm.

func (*Group) Handler

func (g *Group) Handler(name string, data interface{}) http.Handler

Handler returns an http.Handler which serves the named page.

func (*Group) MustParse

func (g *Group) MustParse(name string) *Template

func (*Group) Parse

func (g *Group) Parse(name string) (*Template, error)

New returns a Template loaded using the configured page/layout paths.

func (*Group) SetPrecache

func (g *Group) SetPrecache(precache bool)

type Template

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

func MustParse

func MustParse(name string) *Template

func Parse

func Parse(name string) (*Template, error)

func (*Template) Render

func (t *Template) Render(w io.Writer, data interface{}) error

Jump to

Keyboard shortcuts

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