Documentation
¶
Index ¶
- Constants
- type MustacheParser
- func (c *MustacheParser) Clear()
- func (c *MustacheParser) InitialTokens() []*MustacheToken
- func (c *MustacheParser) OriginalTokens() []*tokenizers.Token
- func (c *MustacheParser) ParseString(mustache string) error
- func (c *MustacheParser) ParseTokens(tokens []*tokenizers.Token) error
- func (c *MustacheParser) ResultTokens() []*MustacheToken
- func (c *MustacheParser) SetOriginalTokens(value []*tokenizers.Token) error
- func (c *MustacheParser) SetTemplate(value string) error
- func (c *MustacheParser) Template() string
- func (c *MustacheParser) VariableNames() []string
- type MustacheToken
Constants ¶
const ( // The unknown ErrCodeUnknown = "UNKNOWN" // The internal error ErrCodeInternal = "INTERNAL" // The unexpected end. ErrCodeUnexpectedEnd = "UNEXPECTED_END" // The error near ErrCodeErrorNear = "ERROR_NEAR" // The error at ErrCodeErrorAt = "ERROR_AT" // The unexpected symbol ErrCodeUnexpectedSymbol = "UNEXPECTED_SYMBOL" // The mismatched brackets ErrCodeMismatchedBrackets = "MISTMATCHED_BRACKETS" // The missing variable ErrCodeMissingVariable = "MISSING_VARIABLE" // Not closed section ErrCodeNotClosedSection = "NOT_CLOSED_SECTION" // Unexpected section end ErrCodeUnexpectedSectionEnd = "UNEXPECTED_SECTION_END" )
General syntax errors
const ( TokenUnknown = iota TokenValue TokenVariable TokenEscapedVariable TokenSection TokenInvertedSection TokenSectionEnd TokenPartial TokenComment )
Define types of mustache tokens
const ( StateValue = iota StateOperator1 StateOperator2 StateVariable StateComment StateClosure )
Define states in mustache lexical analysis
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MustacheParser ¶
type MustacheParser struct {
// contains filtered or unexported fields
}
Implements an mustache parser class.
func NewMustacheParser ¶
func NewMustacheParser() *MustacheParser
func (*MustacheParser) InitialTokens ¶
func (c *MustacheParser) InitialTokens() []*MustacheToken
Gets the list of original mustache tokens.
func (*MustacheParser) OriginalTokens ¶
func (c *MustacheParser) OriginalTokens() []*tokenizers.Token
Gets the list of original tokens
func (*MustacheParser) ParseString ¶
func (c *MustacheParser) ParseString(mustache string) error
Sets a new mustache string and parses it into internal byte code. Parameters:
mustache: A new mustache string.
func (*MustacheParser) ParseTokens ¶
func (c *MustacheParser) ParseTokens(tokens []*tokenizers.Token) error
func (*MustacheParser) ResultTokens ¶
func (c *MustacheParser) ResultTokens() []*MustacheToken
Sets the list of parsed mustache tokens.
func (*MustacheParser) SetOriginalTokens ¶
func (c *MustacheParser) SetOriginalTokens(value []*tokenizers.Token) error
Sets the list of original tokens
func (*MustacheParser) SetTemplate ¶
func (c *MustacheParser) SetTemplate(value string) error
Sets the mustache template.
func (*MustacheParser) Template ¶
func (c *MustacheParser) Template() string
Gets the mustache template.
func (*MustacheParser) VariableNames ¶
func (c *MustacheParser) VariableNames() []string
Gets the list of found variable names.
type MustacheToken ¶
type MustacheToken struct {
// contains filtered or unexported fields
}
Defines an mustache token holder.
func NewMustacheToken ¶
func NewMustacheToken(typ int, value string, line int, column int) *MustacheToken
Creates an instance of a mustache token
Parameters:
- typ: The type of this token.
- value: The value of this token.
- line: The line number where the token is.
- column: The column number where the token is.
func (*MustacheToken) Column ¶
func (c *MustacheToken) Column() int
The column number where the token is.
func (*MustacheToken) SetTokens ¶
func (c *MustacheToken) SetTokens(tokens []*MustacheToken)
Sets a list of subtokens is this token a section.
func (*MustacheToken) Tokens ¶
func (c *MustacheToken) Tokens() []*MustacheToken
Gets a list of subtokens is this token a section.