Documentation ¶
Index ¶
- Constants
- Variables
- func AddFuncs(f FuncMap)
- func DefaultVFS() vfs.VFS
- func NamespacedName(ns []string, name string) string
- func RegisterConverter(ext string, c Converter)
- type CSS
- type Converter
- type FuncMap
- type HTML
- type HTMLAttr
- type Hook
- type JS
- type JSStr
- type State
- type Template
- func (t *Template) AddAssets(groups []*assets.Group) error
- func (t *Template) AddNamespace(ns string)
- func (t *Template) AddParseTree(name string, tree *parse.Tree) error
- func (t *Template) Asset(arg string) (string, error)
- func (t *Template) Assets() []*assets.Group
- func (t *Template) Compile() error
- func (t *Template) ContentType() string
- func (t *Template) Execute(w io.Writer, data interface{}) error
- func (t *Template) ExecuteContext(w io.Writer, data interface{}, context interface{}, vars VarMap) error
- func (t *Template) Funcs(funcs FuncMap) *Template
- func (t *Template) Hook(hook *Hook) error
- func (t *Template) Include(name string) error
- func (t *Template) InsertTemplate(tmpl *Template, name string) error
- func (t *Template) IsFinal() bool
- func (t *Template) Name() string
- func (t *Template) Namespace() string
- func (t *Template) Parse(name string) error
- func (t *Template) ParseVars(name string, vars VarMap) error
- func (t *Template) Root() string
- func (t *Template) SetDropComments(drop bool) error
- func (t *Template) Trees() map[string]*parse.Tree
- type URL
- type VarMap
Constants ¶
const (
AssetFuncName = "asset"
)
Variables ¶
var ( ErrNoAssetsManager = errors.New("template does not have an assets manager") ErrAssetsAlreadyPrepared = errors.New("assets have been already prepared") )
Functions ¶
func AddFuncs ¶
func AddFuncs(f FuncMap)
AddFuncs registers new functions which will be available to the templates. Please, note that you must register the functions before compiling a template that uses them, otherwise the template parser will return an error.
func DefaultVFS ¶
func DefaultVFS() vfs.VFS
DefaultVFS returns a VFS which loads templates from the tmpl directory, relative to the application binary.
func NamespacedName ¶
func RegisterConverter ¶
RegisterConverter registers a template converter for the given extension. If there's already a converter for the given extension, it's overwritten by the new one.
Types ¶
type Converter ¶
Converter represents a function which converts a template source with a given extension into the source of an HTML template. Use RegisterConverter to register your own converters.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the execution state of a template. Users should never create a State manually, but can access its methods via template stat functions.
type Template ¶
type Template struct { AssetsManager *assets.Manager Minify bool Debug bool // contains filtered or unexported fields }
func New ¶
New returns a new template with the given VFS and assets manager. Please, refer to the documention in gopkgs.com/vfs.v1 and gnd.la/template/assets for further information in those types. If the fs is nil, DefaultVFS() will be used.
func Parse ¶
Parse creates a new template using the given VFS and manager and then parses the template with the given name.
func (*Template) AddNamespace ¶
func (*Template) AddParseTree ¶
func (*Template) ContentType ¶
ContentType returns the template content type, usually found by its extension.
func (*Template) ExecuteContext ¶
func (*Template) InsertTemplate ¶
func (*Template) Parse ¶
Parse parses the template starting with the given template name (and following any extends/includes directives declared in it).