mirror of
https://github.com/danog/liquid.git
synced 2024-11-30 04:09:00 +01:00
Merge pull request #59 from carolynvs/expose-ast
Expose the template ast
This commit is contained in:
commit
2aa750df9d
@ -24,6 +24,12 @@ func newTemplate(cfg *render.Config, source []byte, path string, line int) (*Tem
|
||||
return &Template{root, cfg}, nil
|
||||
}
|
||||
|
||||
// GetRoot returns the root node of the abstract syntax tree (AST) representing
|
||||
// the parsed template.
|
||||
func (t *Template) GetRoot() render.Node {
|
||||
return t.root
|
||||
}
|
||||
|
||||
// Render executes the template with the specified variable bindings.
|
||||
func (t *Template) Render(vars Bindings) ([]byte, SourceError) {
|
||||
buf := new(bytes.Buffer)
|
||||
|
@ -9,6 +9,12 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestTemplate_GetRoot(t *testing.T) {
|
||||
root := &render.SeqNode{}
|
||||
tmpl := Template{root: root}
|
||||
require.Same(t, root, tmpl.GetRoot())
|
||||
}
|
||||
|
||||
func TestTemplate_RenderString(t *testing.T) {
|
||||
engine := NewEngine()
|
||||
tpl, err := engine.ParseTemplate([]byte(`{{ "hello world" | capitalize }}`))
|
||||
|
Loading…
Reference in New Issue
Block a user