partials

package
v0.58.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: Apache-2.0 Imports: 11 Imported by: 38

Documentation

Overview

Package partials provides template functions for working with reusable templates.

Index

Constants

This section is empty.

Variables

View Source
var TestTemplateProvider deps.ResourceProvider

TestTemplateProvider is global deps.ResourceProvider. NOTE: It's currently unused.

Functions

This section is empty.

Types

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace provides template functions for the "templates" namespace.

func New

func New(deps *deps.Deps) *Namespace

New returns a new instance of the templates-namespaced template functions.

func (*Namespace) Include

func (ns *Namespace) Include(name string, contextList ...interface{}) (interface{}, error)

Include executes the named partial. If the partial contains a return statement, that value will be returned. Else, the rendered output will be returned: A string if the partial is a text/template, or template.HTML when html/template.

func (*Namespace) IncludeCached added in v0.30.1

func (ns *Namespace) IncludeCached(name string, context interface{}, variant ...string) (interface{}, error)

IncludeCached executes and caches partial templates. An optional variant string parameter (a string slice actually, but be only use a variadic argument to make it optional) can be passed so that a given partial can have multiple uses. The cache is created with name+variant as the key.

Jump to

Keyboard shortcuts

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