Documentation ¶
Overview ¶
Package template allows standard html/template templates to be rendered from contents embedded with the go-bindata tool instead of the filesystem
See https://github.com/jteeuwen/go-bindata for more information about embedding binary data with go-bindata.
Usage example, after running
$ go-bindata data/...
use:
tmpl, err := template.New("mytmpl", Asset).Parse("data/templates/my.tmpl") if err != nil { log.Fatalf("error parsing template: %s", err) } err := tmpl.Execute(os.Stdout) if err != nil { log.Fatalf("error executing template: %s", err) }
Index ¶
- func RetrieveForParse(fn AssetFunc, filenames ...string) (map[string][]byte, error)
- type AssetFunc
- type FuncMap
- type HTML
- type Template
- func (t *Template) AppendBytesToFiles(fileBytes []byte, layout string) (*Template, error)
- func (t *Template) Delims(left, right string) *Template
- func (t *Template) Execute(w io.Writer, data interface{}) error
- func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error
- func (t *Template) Funcs(funcMap FuncMap) *Template
- func (t *Template) Name() string
- func (t *Template) Parse(filename string) (*Template, error)
- func (t *Template) ParseFiles(filenames ...string) (*Template, error)
- func (t *Template) Retrieve() *template.Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RetrieveForParse ¶
RetrieveForParse is a helper function to allow files to be retrieved for combining into a template when they don't share the same Asset function. the returning map can be used to create the final template. Once you have all of these, you can create a large map and then create the template from the bytes
Types ¶
type HTML ¶
type HTML string
HTML is another convenience type that mirrors the HTML type in html/template (http://golang.org/src/html/template/content.go?h=HTML#L120)
type Template ¶
type Template struct { AssetFunc AssetFunc // contains filtered or unexported fields }
Template is a wrapper around a Template (from html/template). It reads template file contents from a function instead of the filesystem.
func Must ¶
Must is a helper that wraps a call to a function returning (*Template, error) and panics if the error is non-nil. It is intended for use in variable initializations such as
var t = template.Must(template.New("name").Parse("templates/my.tmpl"))
func New ¶
New creates a new Template with the given name. It stores the given Asset() function for use later. Example usage:
tmpl := template.New("mytmpl", Asset) //Asset is the function that go-bindata generated for you
func (*Template) AppendBytesToFiles ¶
AppendBytesToFiles attaches a byte array, to the beginning of a template. This can probably be exposed to errors (non template based byte arrays), however for now this is useful for combining templates before they are parsed as html/templates
func (*Template) ExecuteTemplate ¶
ExecuteTemplate is a proxy to the underlying template's ExecuteTemplate function
func (*Template) Parse ¶
Parse looks up the filename in the underlying Asset store, then calls the underlying template's Parse function with the result. returns an error if the file wasn't found or the Parse call failed
func (*Template) ParseFiles ¶
ParseFiles looks up all of the filenames in the underlying Asset store, concatenates the file contents together, then calls the underlying template's Parse function with the result. returns an error if any of the files don't exist or the underlying Parse call failed.