Add int and string cast template funcs
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 15 Jan 2016 22:56:45 +0000 (23:56 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 15 Jan 2016 22:56:45 +0000 (23:56 +0100)
tpl/template_funcs.go

index 3ef36d69457e5e1b1bcf983b6664508981800d6e..498a38c5e95a129d6281bfeed236fcb7425c2c6c 100644 (file)
@@ -1507,6 +1507,8 @@ func init() {
                "relref":       RelRef,
                "apply":        Apply,
                "chomp":        Chomp,
+               "int":          func(v interface{}) int { return cast.ToInt(v) },
+               "string":       func(v interface{}) string { return cast.ToString(v) },
                "replace":      Replace,
                "trim":         Trim,
                "dateFormat":   DateFormat,