tpl

package
v0.0.0-...-8fa2440 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tpl provides facilities for loading and displaying templates.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("template not found")

Returned by TryShow if a template is not found.

View Source
var GetContextFunc func(req *http.Request) interface{}

If this is non-nil, the value returned by this function will always be set as "c" in the args passed to Show.

View Source
var _, Log = xlog.New("web.tpl")

Functions

func GetTemplate

func GetTemplate(name string) *pongo2.Template

Try to find a template with the given name. Returns nil if there is no such template loaded.

func LoadTemplates

func LoadTemplates(dirname string) error

Load all templates from the given directory. The templates must have the file extension ".p2".

func MustShow

func MustShow(req *http.Request, name string, args map[string]interface{})

Show the template with the given name and args. Failure to render the template results in a panic, which will ultimately result in a 500 response.

func Show

func Show(req *http.Request, name string, args map[string]interface{}) error

Try to show the template with the given name and args. Return an error on failure.

The error might be ErrNotFound.

Types

type Formatted

type Formatted string

Formatted represents a stored value which should be displayed formatted.

func (Formatted) SafeHTML

func (f Formatted) SafeHTML() *pongo2.Value

func (*Formatted) Scan

func (f *Formatted) Scan(r *pgx.ValueReader) error

Jump to

Keyboard shortcuts

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