Documentation ¶
Overview ¶
Package plate provides a Recorder for testing Go's HTML templates.
Index ¶
- type Execution
- type Executor
- type Recorder
- func (r *Recorder) Execute(wr io.Writer, data interface{}) error
- func (r *Recorder) ExecuteTemplate(wr io.Writer, name string, data interface{}) error
- func (r *Recorder) Executions() []Execution
- func (r *Recorder) FailedExecutions() []Execution
- func (r *Recorder) LastExecution() Execution
- func (r *Recorder) Reset()
- func (r *Recorder) TimesExecuted() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Execution ¶
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 ¶
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 ¶
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 ¶
New() returns a new Recorder wrapping the given template. It is equivalent to:
&Recorder{Template: tmpl}
func (*Recorder) Execute ¶
Execute executes the wrapped template, saving information into the Recorder.
func (*Recorder) ExecuteTemplate ¶
ExecuteTemplate is like Execute, but for named teplates.
func (*Recorder) Executions ¶
Executions returns all executions that have occured since the construction of a Recorder (or since Reset()).
func (*Recorder) FailedExecutions ¶
FailedExecutions returns all executions that have Error != nil
func (*Recorder) LastExecution ¶
LastExecution returns the information of the latest execution. LastExecution PANICS if no executions have occured yet.
func (*Recorder) Reset ¶
func (r *Recorder) Reset()
Reset clears all executions. Recorder is thus restored to its initial state.
func (*Recorder) TimesExecuted ¶
TimesExecuted returns the count of times template has been executed since construction or calling Reset().