view

package
v0.0.0-...-b76ee76 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2016 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

func ResetConfig

func ResetConfig()

ResetConfig removes the config.

func SetConfig

func SetConfig(i Info)

SetConfig stores the config.

func SetFuncMaps

func 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 SetModifiers

func SetModifiers(fn ...ModifyFunc)

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

func SetTemplates

func SetTemplates(rootTemp string, childTemps []string)

SetTemplates will set the root and child templates.

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 Config

func Config() Info

Config returns the config.

func New

func New(templateList ...string) *Info

New accepts multiple templates and then returns a new view.

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) 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.

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.

Jump to

Keyboard shortcuts

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