1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-27 12:44:53 +01:00
liquid/render.go

37 lines
713 B
Go
Raw Normal View History

2017-06-25 17:23:20 +02:00
package main
import "io"
2017-06-25 22:21:31 +02:00
type Context struct {
Variables map[string]interface{}
}
2017-06-25 17:23:20 +02:00
func (n *ASTSeq) Render(w io.Writer, ctx Context) error {
for _, c := range n.Children {
if err := c.Render(w, ctx); err != nil {
return err
}
}
return nil
}
func (n *ASTChunks) Render(w io.Writer, _ Context) error {
_, err := w.Write([]byte("{chunks}"))
return err
}
func (n *ASTText) Render(w io.Writer, _ Context) error {
_, err := w.Write([]byte(n.chunk.Source))
return err
}
func (n *ASTControlTag) Render(w io.Writer, _ Context) error {
_, err := w.Write([]byte("{control}"))
return err
}
func (n *ASTObject) Render(w io.Writer, _ Context) error {
_, err := w.Write([]byte("{object}"))
return err
}