view

package
v0.0.0-...-3134978 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package view provides thread-safe caching of HTML templates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	BaseURI   string
	Extension string
	Folder    string
	Caching   bool

	Vars map[string]interface{}
	// contains filtered or unexported fields
}

Info holds view attributes.

func (*Info) Base

func (v *Info) Base(base string) *Info

Base sets the new base template instead of reading from Template.Root of the config file.

func (*Info) Get

func (v *Info) Get(w http.ResponseWriter, r *http.Request) error

Get will get the brut view without layout

func (*Info) New

func (v *Info) New(templateList ...string) *Info

New accepts multiple templates and then returns a new view.

func (*Info) Render

func (v *Info) Render(w http.ResponseWriter, r *http.Request) error

Render parses one or more templates and outputs to the screen. Also returns an error if anything is wrong.

func (*Info) SetFuncMaps

func (c *Info) SetFuncMaps(fms ...template.FuncMap)

SetFuncMaps will combine all template.FuncMaps into one map and then set the them for each template. If a func already exists, it is rewritten without a warning.

func (*Info) SetModifiers

func (c *Info) SetModifiers(fn ...ModifyFunc)

SetModifiers will set the modifiers for the View that run before rendering.

func (*Info) SetTemplates

func (c *Info) SetTemplates(rootTemp string, childTemps []string)

SetTemplates will set the root and child templates.

type ModifyFunc

type ModifyFunc func(http.ResponseWriter, *http.Request, *Info)

ModifyFunc can modify the view before rendering.

type Template

type Template struct {
	Root     string   `json:"Root"`
	Children []string `json:"Children"`
}

Template holds the root and children templates.

Directories

Path Synopsis
Package asset contains FuncMap for template packages to provide asset paths with timestamps.
Package asset contains FuncMap for template packages to provide asset paths with timestamps.
viewfunc
link
Package link provides a funcmap for html/template to generate a hyperlink.
Package link provides a funcmap for html/template to generate a hyperlink.
noescape
Package noescape provides a funcmap for html/template to prevent escaping a string.
Package noescape provides a funcmap for html/template to prevent escaping a string.
prettytime
Package prettytime provides a funcmap for html/template that displays time using an easy to read format.
Package prettytime provides a funcmap for html/template that displays time using an easy to read format.
viewmodify
authlevel
Package authlevel adds an AuthLevel variable to the view template.
Package authlevel adds an AuthLevel variable to the view template.
flash
Package flash adds the flashes to the view template.
Package flash adds the flashes to the view template.
uri
Package uri adds URI shortcuts to the view template.
Package uri adds URI shortcuts to the view template.
Package xsrf is a container for the gorilla csrf package
Package xsrf is a container for the gorilla csrf package

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL