Documentation ¶
Overview ¶
Package soyhtml renders a compiled set of Soy to HTML.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTemplateNotFound = errors.New("template not found")
var Funcs = map[string]Func{ "isNonnull": {funcIsNonnull, []int{1}}, "length": {funcLength, []int{1}}, "keys": {funcKeys, []int{1}}, "augmentMap": {funcAugmentMap, []int{2}}, "round": {funcRound, []int{1, 2}}, "floor": {funcFloor, []int{1}}, "ceiling": {funcCeiling, []int{1}}, "min": {funcMin, []int{2}}, "max": {funcMax, []int{2}}, "randomInt": {funcRandomInt, []int{1}}, "strContains": {funcStrContains, []int{2}}, "range": {funcRange, []int{1, 2, 3}}, "hasData": {funcHasData, []int{0}}, }
Funcs contains the builtin soy functions. Callers may add their own functions to this map as well.
var Logger *log.Logger
Logger collects output from {log} commands.
var PrintDirectives = map[string]PrintDirective{ "insertWordBreaks": {directiveInsertWordBreaks, []int{1}, true}, "changeNewlineToBr": {directiveChangeNewlineToBr, []int{0}, true}, "truncate": {directiveTruncate, []int{1, 2}, false}, "id": {directiveNoAutoescape, []int{0}, true}, "noAutoescape": {directiveNoAutoescape, []int{0}, true}, "escapeHtml": {directiveEscapeHtml, []int{0}, true}, "escapeUri": {directiveEscapeUri, []int{0}, true}, "escapeJsString": {directiveEscapeJsString, []int{0}, true}, "bidiSpanWrap": {nil, []int{0}, false}, "bidiUnicodeWrap": {nil, []int{0}, false}, "json": {directiveJson, []int{0}, true}, }
PrintDirectives are the builtin print directives. Callers may add their own print directives to this map.
Functions ¶
Types ¶
type PrintDirective ¶
type PrintDirective struct { Apply func(value data.Value, args []data.Value) data.Value ValidArgLengths []int CancelAutoescape bool }
PrintDirective represents a transformation applied when printing a value.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer provides parameters to template execution. At minimum, Registry and Template are required to render a template..
func (Renderer) Execute ¶
Execute applies a parsed template to the specified data object, and writes the output to wr.
type Tofu ¶
type Tofu struct {
// contains filtered or unexported fields
}
Tofu is a bundle of compiled soy, ready to render to HTML.
func NewTofu ¶
NewTofu returns a new instance that is ready to provide HTML rendering services for the given templates, with the default functions and print directives.
func (*Tofu) NewRenderer ¶
NewRenderer returns a new instance of a soy html renderer, given the fully-qualified name of the template to render.
func (Tofu) Render ¶
Render is a convenience function that executes the soy template of the given name, using the given object (converted to data.Map) as context, and writes the results to the given Writer.
When converting structs to soy's data format, the DefaultStructOptions are used. In particular, note that struct properties are converted to lowerCamel by default, since that is the Soy naming convention. The caller may update those options to change the behavior of this function.