overlay

package module
v0.0.0-...-0c86f5c Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 6 Imported by: 3

README

Overlay

Load golang templates from directory and overlay them with layouts/other templates.

Template, err := overlay.NewTheme(
    "master.tpl", 
    filepath.Join(filepath.Dir("."), "example", "views"),
    "layouts",
)
if err != nil {
    panic(err)
}

//page.tpl extends master.tpl

type pageData struct{
    field string
}

data := pageData{
    field: "hello world!",
}

Template.Render(w, "layouts/page.tpl", data)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Overlay

type Overlay interface {
	Render(w io.Writer, layout string, data interface{}) error
	Extend(parent string, name string, file string) error
}

Overlay collection of template overlays from master

func NewTheme

func NewTheme(f string, dir string, o string) (Overlay, error)

Jump to

Keyboard shortcuts

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