template

package
v0.0.0-...-17ed6e2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(path string) bool

Assert returns true if the path is a valid template. If an error occurs while opening the path or while fetching its FileInfo, panic is called.

func GetName

func GetName(path string) string

GetName takes a path to a template file and returns a path relative to the top-level templates directory with the file extension removed.

func Parse

func Parse(path string)

Parse ensures that the file located at the path specified is a valid template before parsing it into the loaded templates. If any errors occur panic is called. If the path is a directory or does not end with .html, nothing happens.

func ParseAll

func ParseAll()

ParseAll recursively parses all templates within the top-level template directory and its sub-directories. If any errors occur panic is called.

func Render

func Render(w http.ResponseWriter, r *http.Request, tmpl Name, title Title, data Data)

Render renders a template given its name and an arbitrary title.

func WatchAll

func WatchAll()

WatchAll watches the templates directory for changes and re-executes templates when they change. If any errors occur panic is called.

Types

type Data

type Data map[string]interface{}

Data type used to pass data to templates with Render.

type Name

type Name string

Name type represents the relative path to a template.

type Title

type Title string

Title type represents the title of a page.

Jump to

Keyboard shortcuts

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