template

package
v0.0.0-...-c937b9e Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Helper for golang templates Helps to load templates from different directories and assets Based on https://github.com/unrolled/render

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delims

type Delims struct {
	// Left delimiter, defaults to {{.
	Left string
	// Right delimiter, defaults to }}.
	Right string
}

Delims represents a set of Left and Right delimiters for HTML template rendering.

type Opts

type Opts struct {
	// Directory to load templates. Default is "extra/templates".
	Directory string
	// Asset function to use in place of directory. Defaults to nil.
	Asset func(name string) ([]byte, error)
	// AssetNames function to use in place of directory. Defaults to nil.
	AssetNames func() []string
	// Layout template name. Will not render a layout if blank (""). Defaults to blank ("").
	Layout string
	// Extensions to parse template files from. Defaults to [".html"].
	Extensions []string
	// Funcs is a slice of FuncMaps to apply to the template upon compilation. This is useful for helper functions. Defaults to [].
	Funcs []template.FuncMap
	// Delims sets the action delimiters to the specified strings in the Delims struct.
	Delims Delims

	// reload templates automatically
	ReloadTemplates bool
}

type RenderOptions

type RenderOptions struct {
	// Layout template name. Overrides Options.Layout.
	Layout string
}

RenderOptions is a struct for overriding some rendering Options for specific Render call.

type Renderer

type Renderer interface {
	Render(wr io.Writer, name string, binding interface{}, opts ...RenderOptions) error
}

type Template

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

func New

func New(opt *Opts) *Template

func (*Template) Render

func (t *Template) Render(wr io.Writer, name string, binding interface{}, opts ...RenderOptions) error

Jump to

Keyboard shortcuts

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