Documentation ¶
Overview ¶
Package render parses and evaluates template strings.
Index ¶
- func Render(node Node, w io.Writer, vars map[string]interface{}, c Config) error
- type BlockCompiler
- type BlockNode
- type CompilationError
- type Config
- func (c Config) AddBlock(name string) blockDefBuilder
- func (c *Config) AddTag(name string, td TagCompiler)
- func (c Config) BlockSyntax(name string) (parser.BlockSyntax, bool)
- func (c Config) Compile(source string) (parser.ASTNode, error)
- func (c *Config) FindTagDefinition(name string) (TagCompiler, bool)
- type Context
- type Error
- type Node
- type ObjectNode
- type RawNode
- type SeqNode
- type TagCompiler
- type TagNode
- type TextNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockCompiler ¶
BlockCompiler builds a renderer for the tag instance.
type BlockNode ¶
type BlockNode struct { parser.Token Body []Node Branches []*BlockNode // contains filtered or unexported fields }
BlockNode represents a {% tag %}…{% endtag %}.
type CompilationError ¶
type CompilationError string
A CompilationError is a parse error during template compilation.
func (CompilationError) Error ¶
func (e CompilationError) Error() string
type Config ¶
Config holds configuration information for parsing and rendering.
func (*Config) AddTag ¶
func (c *Config) AddTag(name string, td TagCompiler)
AddTag creates a tag definition.
func (Config) BlockSyntax ¶
func (c Config) BlockSyntax(name string) (parser.BlockSyntax, bool)
BlockSyntax is part of the Grammar interface.
func (Config) Compile ¶
Compile parses a source template. It returns an AST root, that can be evaluated.
func (*Config) FindTagDefinition ¶
func (c *Config) FindTagDefinition(name string) (TagCompiler, bool)
FindTagDefinition looks up a tag definition.
type Context ¶
type Context interface { Get(name string) interface{} Evaluate(expr expression.Expression) (interface{}, error) EvaluateString(source string) (interface{}, error) EvaluateStatement(tag, source string) (interface{}, error) ExpandTagArg() (string, error) InnerString() (string, error) RenderChild(io.Writer, *BlockNode) error RenderChildren(io.Writer) error RenderFile(string, map[string]interface{}) (string, error) Set(name string, value interface{}) SourceFile() string TagArgs() string TagName() string }
Context provides the rendering context for a tag renderer.
type ObjectNode ¶
ObjectNode is an {{ object }} object.
type RawNode ¶
type RawNode struct {
// contains filtered or unexported fields
}
RawNode holds the text between the start and end of a raw tag.
type TagCompiler ¶
TagCompiler is a function that parses the tag arguments, and returns a renderer. TODO instead of using the bare function definition, use a structure that defines how to parse