Documentation ¶
Index ¶
- Variables
- func BuffaloRenderer(input string, data map[string]interface{}, helpers map[string]interface{}) (string, error)
- func IsTrue(obj interface{}) bool
- func Render(input string, ctx *Context) (string, error)
- type Context
- type HTMLer
- type HelperContext
- func (h HelperContext) Block() (string, error)
- func (h HelperContext) BlockWith(ctx *Context) (string, error)
- func (h HelperContext) ElseBlock() (string, error)
- func (h HelperContext) ElseBlockWith(ctx *Context) (string, error)
- func (h HelperContext) Get(key string) interface{}
- func (h HelperContext) Helpers() *HelperMap
- type HelperMap
- type Template
Constants ¶
This section is empty.
Variables ¶
var Helpers = HelperMap{ // contains filtered or unexported fields }
Helpers contains all of the default helpers for velvet. These will be available to all templates. You should add any custom global helpers to this list.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds all of the data for the template that is being rendered.
func NewContextWith ¶
NewContextWith returns a fully formed context using the data provided.
func (*Context) New ¶
New context containing the current context. Values set on the new context will not be set onto the original context, however, the original context's values will be available to the new context.
type HelperContext ¶
type HelperContext struct { Context *Context Args []interface{} // contains filtered or unexported fields }
HelperContext is an optional context that can be passed as the last argument to helper functions.
func (HelperContext) Block ¶
func (h HelperContext) Block() (string, error)
Block executes the block of template associated with the helper, think the block inside of an "if" or "each" statement.
func (HelperContext) BlockWith ¶
func (h HelperContext) BlockWith(ctx *Context) (string, error)
BlockWith executes the block of template associated with the helper, think the block inside of an "if" or "each" statement. It takes a new context with which to evaluate the block.
func (HelperContext) ElseBlock ¶
func (h HelperContext) ElseBlock() (string, error)
ElseBlock executes the "inverse" block of template associated with the helper, think the "else" block of an "if" or "each" statement.
func (HelperContext) ElseBlockWith ¶
func (h HelperContext) ElseBlockWith(ctx *Context) (string, error)
ElseBlockWith executes the "inverse" block of template associated with the helper, think the "else" block of an "if" or "each" statement. It takes a new context with which to evaluate the block.
func (HelperContext) Get ¶
func (h HelperContext) Get(key string) interface{}
Get is a convenience method that calls the underlying Context.
func (HelperContext) Helpers ¶
func (h HelperContext) Helpers() *HelperMap
Helpers returns a HelperMap containing all of the known helpers
type HelperMap ¶
type HelperMap struct {
// contains filtered or unexported fields
}
HelperMap holds onto helpers and validates they are properly formed.
func NewHelperMap ¶
NewHelperMap containing all of the "default" helpers from "velvet.Helpers".
func (*HelperMap) Add ¶
Add a new helper to the map. New Helpers will be validated to ensure they meet the requirements for a helper:
func(...) (string) {} func(...) (string, error) {} func(...) (template.HTML) {} func(...) (template.HTML, error) {}
type Template ¶
Template represents an input and helpers to be used to evaluate and render the input.
func NewTemplate ¶
NewTemplate from the input string. Adds all of the global helper functions from "velvet.Helpers".
func (*Template) Clone ¶
Clone a template. This is useful for defining helpers on per "instance" of the template.