template

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package template renders the static files under the "/templates/" directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content struct {
	*bytes.Buffer
}

Content represents the parsed template.

func (*Content) MarshalBinary

func (c *Content) MarshalBinary() ([]byte, error)

MarshalBinary returns the contents as binary and implements the encoding.BinaryMarshaler interface.

type ParseOption

type ParseOption func(t *template.Template) *template.Template

ParseOption represents a functional option for the Parse method.

func WithFuncs

func WithFuncs(fns map[string]interface{}) ParseOption

WithFuncs returns a template that can parse additional custom functions.

type Parser

type Parser interface {
	Parse(path string, data interface{}, options ...ParseOption) (*Content, error)
}

Parser is the interface that wraps the Parse method.

type ReadParser

type ReadParser interface {
	Read(path string) (*Content, error)
	Parser
}

ReadParser is the interface that wraps the Read and Parse methods.

type Template

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

Template represents the "/templates/" directory that holds static files to be embedded in the binary.

func New

func New() *Template

New returns a Template object that can be used to parse files under the "/templates/" directory.

func (*Template) Parse

func (t *Template) Parse(path string, data interface{}, options ...ParseOption) (*Content, error)

Parse parses the template under "/templates/{path}" with the specified data object and returns its content.

func (*Template) Read

func (t *Template) Read(path string) (*Content, error)

Read returns the contents of the template under "/templates/{path}".

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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