view

package
v0.0.0-...-ebdf1d9 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2018 License: MIT Imports: 6 Imported by: 60

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

Jump to

Keyboard shortcuts

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