Skip to content

Commit 3803ae8

Browse files
committed
Pipeline: Don't wrap snapshot in template engine in "Data"
Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com>
1 parent bfb0197 commit 3803ae8

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

pipeline/template_op.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ func (ts *TemplateOp) Do(ctx ActionContext) error {
4141
if len(ts.Path) == 0 {
4242
return ErrPathEmpty
4343
}
44-
val, err := ctx.TemplateEngine().Render(ts.Template, map[string]interface{}{
45-
"Data": ctx.Snapshot(),
46-
})
44+
val, err := ctx.TemplateEngine().Render(ts.Template, ctx.Snapshot())
4745
ctx.Data().AddValueAt(ts.Path, dom.LeafNode(val))
4846
return err
4947
}

pipeline/template_op_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestExecuteTemplateOp(t *testing.T) {
3232
gd = b.Container()
3333
gd.AddValueAt("root.leaf1", dom.LeafNode(123456))
3434
ts = TemplateOp{
35-
Template: `{{ (mul .Data.root.leaf1 2) | quote }}`,
35+
Template: `{{ (mul .root.leaf1 2) | quote }}`,
3636
Path: "result.x1",
3737
}
3838
assert.NoError(t, New(WithData(gd)).Execute(&ts))

0 commit comments

Comments
 (0)