tpl: Add math.Ceil, Floor, and Round to method mappings
authorCameron Moore <moorereason@gmail.com>
Tue, 26 Sep 2017 02:01:59 +0000 (21:01 -0500)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 26 Sep 2017 06:16:24 +0000 (08:16 +0200)
tpl/math/init.go

index 4d740c537c9e24af7d6b206ca8ac133b4ff33353..bbffb23aafd4fcf1fe5d8cff4d0a8c040ff429e8 100644 (file)
@@ -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{