Documentation
¶
Index ¶
- Constants
- Variables
- type CommandPipe
- func (c *CommandPipe) Parse(t *TextWriter, tree *parse.Tree) error
- func (c *CommandPipe) ParseArgs(t *TextWriter, tree *parse.Tree) error
- func (c *CommandPipe) Prepare(set []*parse.CommandNode) error
- func (c *CommandPipe) PrepareCommand(cmd *parse.CommandNode, others []*parse.CommandNode) error
- func (c *CommandPipe) Type() parse.NodeType
- type File
- type Options
- type ParsedData
- func New(text string, functions []map[string]string, sf SourceFileSystem) (*ParsedData, error)
- func Parse(name string, text string, ops Options, funcNames []map[string]string, ...) (*ParsedData, error)
- func ParseTree(name string, text string, ops Options, fset map[string]string, ...) (*ParsedData, error)
- func ParseTreeWithFuncMaps(name string, text string, ops Options, maps parse.FuncMaps, ...) (*ParsedData, error)
- type SourceFileSystem
- type TextWriter
- func (t *TextWriter) AddFuncArg(varName string, varType string)
- func (t *TextWriter) AddFuncNamedReturn(varName string, varType string)
- func (t *TextWriter) AddValueToHtmlListAttr(varName string, content string)
- func (t *TextWriter) AppendNode(rootName string, varName string)
- func (t *TextWriter) BooleanValue(res bool)
- func (t *TextWriter) BooleanVar(varName string, val bool)
- func (t *TextWriter) DotValue()
- func (t *TextWriter) FuncArgEnd()
- func (t *TextWriter) FuncArgStart(varName string, varType string)
- func (t *TextWriter) FuncNamedReturnEnd(varName string, varType string)
- func (t *TextWriter) FuncNamedReturnStart(varName string, varType string)
- func (t *TextWriter) FuncReturns(returnTypes ...string)
- func (t *TextWriter) Identifier(id string)
- func (t *TextWriter) Indent()
- func (t *TextWriter) NewComment(varName string, content string)
- func (t *TextWriter) NewDocument(varName string)
- func (t *TextWriter) NewElement(varName string, tagName string, id string)
- func (t *TextWriter) NewFuncStart(funcName string)
- func (t *TextWriter) NewHtmlAttr(name string, content string, rootNode string)
- func (t *TextWriter) NewHtmlListAttr(varName string, name string)
- func (t *TextWriter) NewLine()
- func (t *TextWriter) NewNode(varName string, nodeType int, tagName string, id string)
- func (t *TextWriter) NewText(varName string, text string)
- func (t *TextWriter) NewVar(varName string, valName string)
- func (t *TextWriter) NewVarStart(varName string)
- func (t *TextWriter) NilValue()
- func (t *TextWriter) NumberValue(constant *parse.NumberNode) error
- func (t *TextWriter) ParseTree() error
- func (t *TextWriter) Reset()
- func (t *TextWriter) Space()
- func (t *TextWriter) SpaceN(length int)
- func (t *TextWriter) StringValue(res string)
- func (t *TextWriter) Var()
- func (t *TextWriter) Write(s string)
- type Treeset
- type VDir
- type VFile
- func (vt *VFile) Parse(ops Options, fns map[string]string) (*ParsedData, error)
- func (vt *VFile) ParseBlock(blockName string, ops Options, fns map[string]string) (*ParsedData, error)
- func (vt *VFile) ParseBlockFor(blockName string, ops Options, fns parse.FuncMaps, treeset Treeset) (*ParsedData, error)
- func (vt *VFile) ParseFor(ops Options, fns parse.FuncMaps, treeset Treeset) (*ParsedData, error)
- func (vt *VFile) Read() (string, error)
- func (vt *VFile) Refresh() error
Constants ¶
const ( DefaultLeftDelimiter = "{{" DefaultRightDelimiter = "}}" )
Variables ¶
var ( DefaultOption = Options{ LeftDelimiter: DefaultLeftDelimiter, RightDelimiter: DefaultRightDelimiter, Packages: nil, } )
Functions ¶
This section is empty.
Types ¶
type CommandPipe ¶
type CommandPipe struct { RootCommander *CommandPipe Root *parse.CommandNode FuncName *parse.IdentifierNode MoreFields []parse.Node Arguments []parse.NodeTyper NoAttaching bool // contains filtered or unexported fields }
func (*CommandPipe) Parse ¶
func (c *CommandPipe) Parse(t *TextWriter, tree *parse.Tree) error
func (*CommandPipe) ParseArgs ¶
func (c *CommandPipe) ParseArgs(t *TextWriter, tree *parse.Tree) error
func (*CommandPipe) Prepare ¶
func (c *CommandPipe) Prepare(set []*parse.CommandNode) error
func (*CommandPipe) PrepareCommand ¶
func (c *CommandPipe) PrepareCommand(cmd *parse.CommandNode, others []*parse.CommandNode) error
func (*CommandPipe) Type ¶
func (c *CommandPipe) Type() parse.NodeType
type File ¶
type File interface { Refresh() error Read() (string, error) Parse(ops Options, ms map[string]string) (*ParsedData, error) ParseFor(ops Options, fm parse.FuncMaps, t Treeset) (*ParsedData, error) ParseBlock(blockName string, ops Options, ms map[string]string) (*ParsedData, error) ParseBlockFor(blockName string, ops Options, fm parse.FuncMaps, t Treeset) (*ParsedData, error) }
File represents a actually file (be it memory or local) which contains contents which can be refreshed to get the latest content.
type Options ¶
type Options struct { LeftDelimiter string RightDelimiter string // Packages contain packages we wish added // into import path. It provides an alternative // to one declared directly in the template using // the {{import ... }} directive. // // The key is the alias and value the package path which // is to be imported. Packages map[string]string // contains filtered or unexported fields }
Options contains config fields for the TextWriter.
type ParsedData ¶
type ParsedData struct {
// contains filtered or unexported fields
}
func New ¶
func New(text string, functions []map[string]string, sf SourceFileSystem) (*ParsedData, error)
func Parse ¶
func Parse(name string, text string, ops Options, funcNames []map[string]string, sf SourceFileSystem, tset Treeset) (*ParsedData, error)
Parse parses provided string into underline collector.
@param(require): name represent the special name to represent this parsed tree @param(required): text contains the content to be parsed @param(required): functions is the list of maps defining actions that should be considered functions @param(required): sf is the root file system to be used when retrieving template blocks for parsing @param(optional): tset is the previous Treeset from a previous run where this is considered a child of.
func ParseTree ¶
func ParseTree(name string, text string, ops Options, fset map[string]string, sf SourceFileSystem, tset Treeset) (*ParsedData, error)
func ParseTreeWithFuncMaps ¶
func ParseTreeWithFuncMaps(name string, text string, ops Options, maps parse.FuncMaps, sf SourceFileSystem, set Treeset) (*ParsedData, error)
type SourceFileSystem ¶
SourceFileSystem embodies a provider which allows retrieval of specific sources based on giving unique name.
type TextWriter ¶
type TextWriter struct { TreeSet Treeset KomponentBuilder *strings.Builder // contains filtered or unexported fields }
TextWriter implements a template to go parser.
func (*TextWriter) AddFuncArg ¶
func (t *TextWriter) AddFuncArg(varName string, varType string)
func (*TextWriter) AddFuncNamedReturn ¶
func (t *TextWriter) AddFuncNamedReturn(varName string, varType string)
func (*TextWriter) AddValueToHtmlListAttr ¶
func (t *TextWriter) AddValueToHtmlListAttr(varName string, content string)
func (*TextWriter) AppendNode ¶
func (t *TextWriter) AppendNode(rootName string, varName string)
func (*TextWriter) BooleanValue ¶
func (t *TextWriter) BooleanValue(res bool)
func (*TextWriter) BooleanVar ¶
func (t *TextWriter) BooleanVar(varName string, val bool)
func (*TextWriter) DotValue ¶
func (t *TextWriter) DotValue()
func (*TextWriter) FuncArgEnd ¶
func (t *TextWriter) FuncArgEnd()
func (*TextWriter) FuncArgStart ¶
func (t *TextWriter) FuncArgStart(varName string, varType string)
func (*TextWriter) FuncNamedReturnEnd ¶
func (t *TextWriter) FuncNamedReturnEnd(varName string, varType string)
func (*TextWriter) FuncNamedReturnStart ¶
func (t *TextWriter) FuncNamedReturnStart(varName string, varType string)
func (*TextWriter) FuncReturns ¶
func (t *TextWriter) FuncReturns(returnTypes ...string)
func (*TextWriter) Identifier ¶
func (t *TextWriter) Identifier(id string)
func (*TextWriter) Indent ¶
func (t *TextWriter) Indent()
func (*TextWriter) NewComment ¶
func (t *TextWriter) NewComment(varName string, content string)
func (*TextWriter) NewDocument ¶
func (t *TextWriter) NewDocument(varName string)
func (*TextWriter) NewElement ¶
func (t *TextWriter) NewElement(varName string, tagName string, id string)
func (*TextWriter) NewFuncStart ¶
func (t *TextWriter) NewFuncStart(funcName string)
func (*TextWriter) NewHtmlAttr ¶
func (t *TextWriter) NewHtmlAttr(name string, content string, rootNode string)
func (*TextWriter) NewHtmlListAttr ¶
func (t *TextWriter) NewHtmlListAttr(varName string, name string)
func (*TextWriter) NewLine ¶
func (t *TextWriter) NewLine()
func (*TextWriter) NewNode ¶
func (t *TextWriter) NewNode(varName string, nodeType int, tagName string, id string)
func (*TextWriter) NewText ¶
func (t *TextWriter) NewText(varName string, text string)
func (*TextWriter) NewVar ¶
func (t *TextWriter) NewVar(varName string, valName string)
func (*TextWriter) NewVarStart ¶
func (t *TextWriter) NewVarStart(varName string)
func (*TextWriter) NilValue ¶
func (t *TextWriter) NilValue()
func (*TextWriter) NumberValue ¶
func (t *TextWriter) NumberValue(constant *parse.NumberNode) error
func (*TextWriter) ParseTree ¶
func (t *TextWriter) ParseTree() error
ParseTree parses the tree with provided Treeset and parent.
func (*TextWriter) Reset ¶
func (t *TextWriter) Reset()
func (*TextWriter) Space ¶
func (t *TextWriter) Space()
func (*TextWriter) SpaceN ¶
func (t *TextWriter) SpaceN(length int)
func (*TextWriter) StringValue ¶
func (t *TextWriter) StringValue(res string)
func (*TextWriter) Var ¶
func (t *TextWriter) Var()
func (*TextWriter) Write ¶
func (t *TextWriter) Write(s string)
type VDir ¶
type VDir struct {
// contains filtered or unexported fields
}
VDir implements SourceFileSystem provided a caching system for files and directories.
type VFile ¶
type VFile struct {
// contains filtered or unexported fields
}
func NewVFileWithFS ¶
func NewVFileWithFS(targetFile string, fs SourceFileSystem) *VFile
NewVFileWithFS returns a new VFile with associated fs.
func (*VFile) Parse ¶
Parse parses the content of the File using the miru.TextWriter returning a strings.Builder containing the parsed content.
func (*VFile) ParseBlock ¶
func (vt *VFile) ParseBlock(blockName string, ops Options, fns map[string]string) (*ParsedData, error)
ParseBlock parses the content of the File using the miru.TextWriter returning a strings.Builder containing the parsed content.
func (*VFile) ParseBlockFor ¶
func (vt *VFile) ParseBlockFor(blockName string, ops Options, fns parse.FuncMaps, treeset Treeset) (*ParsedData, error)
ParseBlockFor parses the content of the File using the miru.TextWriter returning a strings.Builder containing the parsed content.
func (*VFile) ParseFor ¶
ParseFor parses the content of the File using the miru.TextWriter returning a strings.Builder containing the parsed content.
Directories
¶
Path | Synopsis |
---|---|
package escaper provides functions for escaping and unescaping HTML text.
|
package escaper provides functions for escaping and unescaping HTML text. |
Package parse builds parse trees for templates as defined by text/template and html/template.
|
Package parse builds parse trees for templates as defined by text/template and html/template. |