commit 8a69d2356703d9f2fcb75bce0ae514e70ebd8e01
parent d9697e275ecb038958b3dcea2b43e11dcba28fc9
Author: Cameron Moore <moorereason@gmail.com>
Date: Mon, 25 Sep 2017 21:01:59 -0500
tpl: Add math.Ceil, Floor, and Round to method mappings
Diffstat:
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/tpl/math/init.go b/tpl/math/init.go
@@ -36,6 +36,13 @@ func init() {
},
)
+ ns.AddMethodMapping(ctx.Ceil,
+ nil,
+ [][2]string{
+ {"{{math.Ceil 2.1}}", "3"},
+ },
+ )
+
ns.AddMethodMapping(ctx.Div,
[]string{"div"},
[][2]string{
@@ -43,6 +50,13 @@ func init() {
},
)
+ ns.AddMethodMapping(ctx.Floor,
+ nil,
+ [][2]string{
+ {"{{math.Floor 1.9}}", "1"},
+ },
+ )
+
ns.AddMethodMapping(ctx.Log,
nil,
[][2]string{
@@ -71,6 +85,13 @@ func init() {
},
)
+ ns.AddMethodMapping(ctx.Round,
+ nil,
+ [][2]string{
+ {"{{math.Round 1.5}}", "2"},
+ },
+ )
+
ns.AddMethodMapping(ctx.Sub,
[]string{"sub"},
[][2]string{