From 714f5a6adeea0b7c4be75b123a6398afee985a36 Mon Sep 17 00:00:00 2001 From: Pavel Vlasov Date: Fri, 15 Aug 2014 16:26:41 +0400 Subject: [PATCH] Allow to access functions from FuncMap Seems, that calling only works for built-in functions, because ``` #{foo($bar)} ``` transforms into `{{call .foo $bar}}`, but should be without `.` character. More elegant solutions are welcome :) --- compiler.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler.go b/compiler.go index 004b1c0..499e1f0 100644 --- a/compiler.go +++ b/compiler.go @@ -668,8 +668,13 @@ func (c *Compiler) visitExpression(outerexpr ast.Expr) string { stack.PushFront(ce.Fun.(*ast.Ident).Name) c.write(`{{` + name + ` := ` + pop()) } else { - exec(ce.Fun) - c.write(`{{` + name + ` := call ` + pop()) + switch ce.Fun.(type) { + case *ast.Ident: + stack.PushFront(ce.Fun.(*ast.Ident).Name) + default: + exec(ce.Fun) + } + c.write(`{{` + name + ` := ` + pop()) } for i := 0; i < len(ce.Args); i++ {