Documentation ¶
Overview ¶
Package gview implements a template engine based on text/template.
Index ¶
- Constants
- func ParseContent(content string, params Params) (string, error)
- type FuncMap
- type Params
- type View
- func (view *View) AddPath(path string) error
- func (view *View) Assign(key string, value interface{})
- func (view *View) Assigns(data Params)
- func (view *View) BindFunc(name string, function interface{})
- func (view *View) BindFuncMap(funcMap FuncMap)
- func (view *View) Parse(file string, params ...Params) (parsed string, err error)
- func (view *View) ParseContent(content string, params ...Params) (string, error)
- func (view *View) SetDelimiters(left, right string)
- func (view *View) SetI18n(manager *gi18n.Manager)
- func (view *View) SetPath(path string) error
Constants ¶
const (
// Default group name for instance usage.
DEFAULT_NAME = "default"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type View ¶
type View struct {
// contains filtered or unexported fields
}
View object for template engine.
func Instance ¶
Instance returns an instance of View with default settings. The parameter <name> is the name for the instance.
func New ¶
New returns a new view object. The parameter <path> specifies the template directory path to load template files.
func (*View) Assign ¶
Assign binds a template variable to current view object. Each goroutine will take effect after the call, so it is concurrent-safe.
func (*View) Assigns ¶
Assign binds multiple template variables to current view object. Each goroutine will take effect after the call, so it is concurrent-safe.
func (*View) BindFunc ¶
BindFunc registers customized template function named <name> with given function <function> to current view object. The <name> is the function name which can be called in template content.
func (*View) BindFuncMap ¶
BindFuncMap registers customized template functions by map to current view object. The key of map is the template function name and the value of map is the address of customized function.
func (*View) Parse ¶
ParseContent parses given template file <file> with given template parameters <params> and function map <funcMap> and returns the parsed string content.
func (*View) ParseContent ¶
ParseContent parses given template content <content> with given template parameters <params> and function map <funcMap> and returns the parsed content in []byte.
func (*View) SetDelimiters ¶
SetDelimiters sets customized delimiters for template parsing.