2017-07-07 11:41:37 +02:00
|
|
|
package parser
|
2017-06-25 17:23:20 +02:00
|
|
|
|
|
|
|
import (
|
2017-07-04 17:12:40 +02:00
|
|
|
"github.com/osteele/liquid/expression"
|
2017-06-25 17:23:20 +02:00
|
|
|
)
|
|
|
|
|
2017-06-26 18:41:41 +02:00
|
|
|
// ASTNode is a node of an AST.
|
2017-07-06 15:35:12 +02:00
|
|
|
type ASTNode interface{}
|
2017-07-06 14:59:10 +02:00
|
|
|
|
|
|
|
// ASTBlock represents a {% tag %}…{% endtag %}.
|
|
|
|
type ASTBlock struct {
|
|
|
|
Chunk
|
2017-07-06 15:35:12 +02:00
|
|
|
syntax BlockSyntax
|
|
|
|
Body []ASTNode // Body is the nodes before the first branch
|
|
|
|
Branches []*ASTBlock // E.g. else and elseif w/in an if
|
2017-06-25 17:23:20 +02:00
|
|
|
}
|
|
|
|
|
2017-06-27 23:40:15 +02:00
|
|
|
// ASTRaw holds the text between the start and end of a raw tag.
|
|
|
|
type ASTRaw struct {
|
2017-07-07 11:41:37 +02:00
|
|
|
Slices []string
|
2017-06-27 23:40:15 +02:00
|
|
|
}
|
|
|
|
|
2017-07-06 15:35:12 +02:00
|
|
|
// ASTTag is a tag.
|
|
|
|
type ASTTag struct {
|
2017-06-28 02:23:09 +02:00
|
|
|
Chunk
|
2017-06-26 21:36:05 +02:00
|
|
|
}
|
|
|
|
|
2017-06-27 17:19:12 +02:00
|
|
|
// ASTText is a text chunk, that is rendered verbatim.
|
2017-06-25 17:23:20 +02:00
|
|
|
type ASTText struct {
|
2017-06-27 17:19:12 +02:00
|
|
|
Chunk
|
2017-06-25 17:23:20 +02:00
|
|
|
}
|
|
|
|
|
2017-06-27 17:19:12 +02:00
|
|
|
// ASTObject is an {{ object }} object.
|
2017-06-25 17:23:20 +02:00
|
|
|
type ASTObject struct {
|
2017-06-27 17:19:12 +02:00
|
|
|
Chunk
|
2017-07-07 11:41:37 +02:00
|
|
|
Expr expression.Expression
|
2017-06-25 17:23:20 +02:00
|
|
|
}
|
|
|
|
|
2017-07-06 14:59:10 +02:00
|
|
|
// ASTSeq is a sequence of nodes.
|
|
|
|
type ASTSeq struct {
|
|
|
|
Children []ASTNode
|
2017-06-25 17:23:20 +02:00
|
|
|
}
|