ion: Index | Files

package render

import ""

Package render provides a little sugar to the usage of standard Go templates. It allows to easily load templates and to setup functions and "inheritance". Based on ideas taken from


Package Files


type Templates Uses

type Templates struct {
    // contains filtered or unexported fields

Templates facilitates usage of templates with inheritance

func New Uses

func New() *Templates

New creates a new template manager

func (*Templates) AddFunc Uses

func (t *Templates) AddFunc(name string, fun interface{})

AddFunc adds a new function to the map of functions. All the functions must be added before adding templates or base layouts.

func (*Templates) AddTemplate Uses

func (t *Templates) AddTemplate(fileglob string) error

AddTemplate creates a new template, with the same name as the file (without extension). The template is based on the current top of the stack.

func (*Templates) Execute Uses

func (t *Templates) Execute(w io.Writer, base, name string, data interface{}) error

Execute renders the template with the given name, using the base layout, io.Writer and data given.

func (*Templates) Peek Uses

func (t *Templates) Peek() *template.Template

Peek returns the current top of the "base template" stack

func (*Templates) Pop Uses

func (t *Templates) Pop()

Pop removes a "base template" from the stack

func (*Templates) Push Uses

func (t *Templates) Push(path string) (err error)

Push adds a set of files (path is a regex) to the stack of "base templates". If err is non-nil then the stack is left untouched. The new template is based on the previous top of the stack.

Package render imports 5 packages (graph). Updated 2017-02-02. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).