plate: github.com/justinas/plate Index | Files

package plate

import "github.com/justinas/plate"

Package plate provides a Recorder for testing Go's HTML templates.

Index

Package Files

executor.go recorder.go

type Execution Uses

type Execution struct {
    Output  []byte
    Context interface{}

    Error error
}

Execution represents one occurence of template being executed. It provides access to the output produced, the context that was passed to the template and the error returned from the Execute*() function, if any.

type Executor Uses

type Executor interface {
    Execute(wr io.Writer, data interface{}) error
    ExecuteTemplate(wr io.Writer, name string, data interface{}) error
}

Executor is an interface comprised of the metods that html/template and text/template use to render themselves. Thus any *template.Template implements Executor automatically.

type Recorder Uses

type Recorder struct {
    // The original template to wrap.
    Template Executor
    // contains filtered or unexported fields
}

Recorder wraps an Executor and records results of executions for later checks.

func New Uses

func New(tmpl Executor) *Recorder

New() returns a new Recorder wrapping the given template. It is equivalent to:

&Recorder{Template: tmpl}

func (*Recorder) Execute Uses

func (r *Recorder) Execute(wr io.Writer, data interface{}) error

Execute executes the wrapped template, saving information into the Recorder.

func (*Recorder) ExecuteTemplate Uses

func (r *Recorder) ExecuteTemplate(wr io.Writer, name string, data interface{}) error

ExecuteTemplate is like Execute, but for named teplates.

func (*Recorder) Executions Uses

func (r *Recorder) Executions() []Execution

Executions returns all executions that have occured since the construction of a Recorder (or since Reset()).

func (*Recorder) FailedExecutions Uses

func (r *Recorder) FailedExecutions() []Execution

FailedExecutions returns all executions that have Error != nil

func (*Recorder) LastExecution Uses

func (r *Recorder) LastExecution() Execution

LastExecution returns the information of the latest execution. LastExecution PANICS if no executions have occured yet.

func (*Recorder) Reset Uses

func (r *Recorder) Reset()

Reset clears all executions. Recorder is thus restored to its initial state.

func (*Recorder) TimesExecuted Uses

func (r *Recorder) TimesExecuted() int

TimesExecuted returns the count of times template has been executed since construction or calling Reset().

Package plate imports 3 packages (graph). Updated 2016-07-21. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).