Documentation
¶
Overview ¶
Package template loads Go html/template files and renders pages with site data.
Package template loads Go html/template files and renders articles into HTML.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the concrete implementation of TemplateEngine. It loads html/template files from a theme directory and renders pages with site/article data.
func NewEngine ¶
func NewEngine() *Engine
NewEngine returns a new, empty Engine. Call Load before calling Render.
func (*Engine) Load ¶
Load parses all .html files found (recursively) under templateDir. Built-in helper functions (formatDate, tagURL, categoryURL, markdownify) are registered automatically; callers may supply additional functions via funcs. defaultLocale is the site's primary locale (e.g. "en"); pass "" for non-i18n sites. tagURL and categoryURL use it to decide when to omit the locale prefix.
type TemplateEngine ¶
type TemplateEngine interface {
// Load parses all template files rooted at templateDir (e.g. theme/templates).
// defaultLocale is the site's primary locale (e.g. "en"); pass "" for
// non-i18n sites. tagURL and categoryURL use it to decide when to omit the
// locale prefix.
Load(templateDir string, funcs template.FuncMap, defaultLocale string) error
// Render executes the named template with the given data, writing the result
// to w. templateName corresponds to a file base name such as "article.html".
Render(w io.Writer, templateName string, data *model.Site) error
}
TemplateEngine loads theme templates from disk and renders pages using the standard library html/template package.