templateutil

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2016 License: MIT Imports: 8 Imported by: 4

Documentation

Overview

Package templateutil features LazyTemplate and TemplateWriter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustInit

func MustInit(lt *LazyTemplate)

MustInit is a Must func for LazyTemplate.

Types

type InfoFunc

type InfoFunc func(string) (os.FileInfo, error)

InfoFunc type is shortcut for AssetInfo-type func.

type LazyTemplate

type LazyTemplate struct {
	MU sync.Mutex // protects everything

	// arguments to NewLT (all required)
	ReadFunc ReadFunc
	InfoFunc InfoFunc
	Filename string
	Funcmap  template.FuncMap

	// operationals
	NonDev     bool
	DevModTime time.Time
	Template   *template.Template
	Err        error
}

LazyTemplate has a template.Template. Lazy parse , always clone for bin templates , sometimes re-parse for dev-bins . NewLT is the constructor.

func NewLT

func NewLT(readfunc ReadFunc, infofunc InfoFunc, filename string, funcmap template.FuncMap) *LazyTemplate

NewLT constructs LazyTemplate.

func (*LazyTemplate) Apply

func (lt *LazyTemplate) Apply(w http.ResponseWriter, data interface{})

Apply clones .Template to execute it into w.

func (*LazyTemplate) Init

func (lt *LazyTemplate) Init()

Init is internal and lock-free.

type ReadFunc

type ReadFunc func(string) ([]byte, error)

ReadFunc type is shortcut for Asset-type func.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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