Documentation ¶
Overview ¶
Package pages provides template loading and rendering.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ReloadTemplates = false
ReloadTemplates is a flag for whether NewPage should reload templates on every request. Reloading templates is useful to see changes without recompiling. In production, reloading should be disabled.
Functions ¶
This section is empty.
Types ¶
type Breadcrumb ¶
Breadcrumb represents a navigation breadcrumb.
type Breadcrumbs ¶
type Breadcrumbs []*Breadcrumb
Breadcrumbs manages navigation breadcrumbs.
func (*Breadcrumbs) Add ¶
func (b *Breadcrumbs) Add(breadcrumbs ...*Breadcrumb)
Add adds breadcrumbs.
func (*Breadcrumbs) AddNew ¶
func (b *Breadcrumbs) AddNew(title string, url *url.URL) *Breadcrumb
AddNew creates a new breadcrumb and adds it.
func (*Breadcrumbs) GetAll ¶
func (b *Breadcrumbs) GetAll() []*Breadcrumb
GetAll returns all breadcrumbs.
func (*Breadcrumbs) Remove ¶
func (b *Breadcrumbs) Remove(breadcrumbs ...*Breadcrumb)
Remove removes breadcrumbs.
func (*Breadcrumbs) RemoveAll ¶
func (b *Breadcrumbs) RemoveAll()
RemoveAll removes all breadcrumbs.
type Page ¶
type Page struct { // BaseURL to prepend to redirect URL. BaseURL string // Breadcrumbs represent a hierarchical navigation. Breadcrumbs *Breadcrumbs // Data for populating the template. Data map[string]interface{} // Form helper for creating HTML input elements in the template. Form *forms.Form // Language to use for displaying text. Language *languages.Language // Name of the page. Useful for styling links to the current page // differently. Name string // Session associated with the request. Session sessions.Session // Template to render when calling Serve. Template *Template // Title of the page. Useful for populating the HTML title element. Title string // contains filtered or unexported fields }
Page represents an HTML page.
func (*Page) FlashAll ¶
FlashAll returns all flashes, removes them from session and saves the session if necessary.
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template is a collection of (nested) template files.
func MustNewTemplate ¶
MustNewTemplate calls NewTemplate. It panics on error.
func NewTemplate ¶
NewTemplate creates a template from template files specified by paths. If the template files are supposed to use functions other than the built-in Go functions, these functions must be provided through funcMap.