Documentation ¶
Overview ¶
Package viewutil provides utilities and common templates for views across all packages.
Index ¶
- Variables
- func Base(meta Meta, title, body string, bodyAttributes map[string]string, ...) string
- func ExecutePage(meta Meta, chain Chain, data interface{ ... })
- func HandlerNotFound(w http.ResponseWriter, _ *http.Request)
- func HttpErr(meta Meta, status int, name, errMsg string)
- func Init()
- type BaseData
- type Chain
- type HeaderLink
- type Meta
Constants ¶
This section is empty.
Variables ¶
var ( BaseEn *template.Template BaseRu *template.Template )
var HeaderLinks []HeaderLink
HeaderLinks is a list off current header links. Feel free to iterate it directly but do not modify it by yourself. Call ParseHeaderLinks if you need to set new header links.
Functions ¶
func Base ¶
func Base(meta Meta, title, body string, bodyAttributes map[string]string, headElements ...string) string
Base is a temporary wrapper around BaseEn and BaseRu, meant to facilitate the migration from qtpl. TODO: get rid of this
func ExecutePage ¶
func ExecutePage(meta Meta, chain Chain, data interface { withBaseValues(meta Meta, headerLinks []HeaderLink, commonScripts []string) })
ExecutePage executes template page in the given chain with the given data that has BaseData nested. It also sets some common BaseData fields
func HandlerNotFound ¶
func HandlerNotFound(w http.ResponseWriter, _ *http.Request)
HandlerNotFound prints the simples 404 page. Use in rare places that cannot be achieved normally.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain represents a chain of different language versions of the same template.
type HeaderLink ¶
type HeaderLink struct { // Href is the URL of the link. It goes <a href="here">...</a>. Href string // Display is what is shown when the link is rendered. It goes <a href="...">here</a>. Display string }
HeaderLink represents a header link. Header links are the links shown in the top gray bar.
type Meta ¶
type Meta struct { Lc *l18n.Localizer U *user.User W io.Writer Addr string // New template additions HeadElements []template.HTML BodyAttributes map[string]string }
Meta is a bundle of common stuffs used by views, templates.
func MetaFrom ¶
func MetaFrom(w http.ResponseWriter, rq *http.Request) Meta
MetaFrom makes a Meta from the given data. You are meant to further modify it.