templates

package
v0.0.0-...-0bc05a2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2016 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attrs

type Attrs map[string]interface{}

func AsJSON

func AsJSON(key string, value interface{}) (attrs Attrs)

func (Attrs) Merge

func (a Attrs) Merge(b map[string]interface{})

type Templates

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

Templates holds the parsed template files and any local attributes.

func Empty

func Empty() *Templates

Empty Creates an empty Templates

func New

func New(path string, attrs ...Attrs) *Templates

New creates a new Templates instance by compiling all files recursively in the given directory. Panics on error.

func NewWithDelims

func NewWithDelims(path, openTag, closeTag string, attrs ...Attrs) *Templates

New creates a new Templates instance by compiling all files recursively in the given directory using the given delimiters. Panics on error.

func (*Templates) Add

func (t *Templates) Add(src string) error

Add adds a template to the current parsed templates

func (*Templates) Execute

func (t *Templates) Execute(w io.Writer, n string, attrs ...Attrs)

Execute will render the given template define name with the given attrs. Panics on error, because that's how we roll.

func (*Templates) SetAttr

func (t *Templates) SetAttr(key string, value interface{}) (err error)

SetAttr sets a local templates variable. Overwritten variables return an error, which can be ignored as needed.

Jump to

Keyboard shortcuts

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