1
0
mirror of https://github.com/danog/liquid.git synced 2024-12-02 14:47:46 +01:00
liquid/render/ast.go

50 lines
980 B
Go
Raw Normal View History

2017-07-04 17:03:18 +02:00
package render
2017-06-25 17:23:20 +02:00
import (
"io"
"github.com/osteele/liquid/expressions"
2017-06-25 17:23:20 +02:00
)
2017-06-26 18:41:41 +02:00
// ASTNode is a node of an AST.
type ASTNode interface {
2017-06-29 18:26:04 +02:00
// Render evaluates an AST node and writes the result to an io.Writer.
// Render(io.Writer, Context) error
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 {
slices []string
}
2017-06-27 17:19:12 +02:00
// ASTSeq is a sequence of nodes.
2017-06-25 17:23:20 +02:00
type ASTSeq struct {
2017-06-26 18:41:41 +02:00
Children []ASTNode
2017-06-25 17:23:20 +02:00
}
// ASTFunctional renders itself via a render function that is created during parsing.
type ASTFunctional struct {
Chunk
2017-06-30 20:51:21 +02:00
render func(io.Writer, RenderContext) error
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
expr expressions.Expression
2017-06-25 17:23:20 +02:00
}
2017-07-03 18:00:43 +02:00
// ASTBlock represents a {% tag %}…{% endtag %}.
type ASTBlock struct {
2017-06-27 17:19:12 +02:00
Chunk
2017-06-30 20:51:21 +02:00
renderer func(io.Writer, RenderContext) error
cd *blockDef
2017-06-27 17:39:32 +02:00
Body []ASTNode
2017-07-03 18:00:43 +02:00
Branches []*ASTBlock
2017-06-25 17:23:20 +02:00
}