Documentation
¶
Overview ¶
Package template 基于 pongo2 的多站点模板引擎,支持 RegisterTag
Package template 自定义 tag 示例
Index ¶
- func TagUppercaseParser(doc *pongo2.Parser, start *pongo2.Token, arguments *pongo2.Parser) (pongo2.INodeTag, *pongo2.Error)
- type SitesEngine
- func (e *SitesEngine) AddFunc(name string, fn interface{}) *SitesEngine
- func (e *SitesEngine) Load() error
- func (e *SitesEngine) RegisterTag(name string, parser pongo2.TagParser)
- func (e *SitesEngine) Render(out io.Writer, name string, binding interface{}, layout ...string) error
- func (e *SitesEngine) SetAutoEscape(v bool) *SitesEngine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SitesEngine ¶
type SitesEngine struct {
core.Engine
Templates map[string]*pongo2.Template // key: "theme/name"
// contains filtered or unexported fields
}
SitesEngine 多站点 pongo2 模板引擎 目录结构: baseDir/template/{theme}/index.django, baseDir/template/{theme}/layouts/main.django binding 中需包含 Theme 或 siteBase.Template 以确定当前站点模板
func New ¶
func New(baseDir, extension string) *SitesEngine
New 创建多站点模板引擎 baseDir: 模板根目录,如 "views" extension: 模板扩展名,如 ".django"
func (*SitesEngine) AddFunc ¶
func (e *SitesEngine) AddFunc(name string, fn interface{}) *SitesEngine
AddFunc 添加模板函数
func (*SitesEngine) RegisterTag ¶
func (e *SitesEngine) RegisterTag(name string, parser pongo2.TagParser)
RegisterTag 注册自定义 pongo2 tag,需在 Load 之前调用
func (*SitesEngine) Render ¶
func (e *SitesEngine) Render(out io.Writer, name string, binding interface{}, layout ...string) error
Render 渲染模板,根据 binding 中的 Theme/siteBase 选择站点模板
func (*SitesEngine) SetAutoEscape ¶
func (e *SitesEngine) SetAutoEscape(v bool) *SitesEngine
SetAutoEscape 设置自动转义
Click to show internal directories.
Click to hide internal directories.