templateutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2015 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 CombineMaps

func CombineMaps(f Functor, extra template.FuncMap) template.FuncMap

CombineMaps makes new template.FuncMap off f implementation and extra.

func FuncMapHTML

func FuncMapHTML() template.FuncMap

func FuncMapJSXL

func FuncMapJSXL() template.FuncMap

func MustInit

func MustInit(lt *LazyTemplate)

MustInit is a Must func for LazyTemplate.

Types

type Functor

type Functor interface {
	Class() string
	Colspan() string
	JSX(string) template.HTML
}

type HTMLFuncs

type HTMLFuncs struct{}

HTMLFuncs has methods implementing Functor.

func NewHTMLFuncs

func NewHTMLFuncs() HTMLFuncs

func (HTMLFuncs) Class

func (f HTMLFuncs) Class() string

func (HTMLFuncs) Colspan

func (f HTMLFuncs) Colspan() string

func (HTMLFuncs) JSX

func (f HTMLFuncs) JSX(string) (_ template.HTML)

type InfoFunc

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

InfoFunc type is shortcut for AssetInfo-type func.

type JSXLFuncs

type JSXLFuncs struct{}

JSXLFuncs has methods implementing Functor.

func NewJSXLFuncs

func NewJSXLFuncs() JSXLFuncs

func (JSXLFuncs) Class

func (f JSXLFuncs) Class() string

func (JSXLFuncs) Colspan

func (f JSXLFuncs) Colspan() string

func (JSXLFuncs) JSX

func (f JSXLFuncs) JSX(s string) template.HTML

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