shithub: hugo

Download patch

ref: 8a69d2356703d9f2fcb75bce0ae514e70ebd8e01
parent: d9697e275ecb038958b3dcea2b43e11dcba28fc9
author: Cameron Moore <[email protected]>
date: Mon Sep 25 17:01:59 EDT 2017

tpl: Add math.Ceil, Floor, and Round to method mappings

--- a/tpl/math/init.go
+++ b/tpl/math/init.go
@@ -36,6 +36,13 @@
 			},
 		)
 
+		ns.AddMethodMapping(ctx.Ceil,
+			nil,
+			[][2]string{
+				{"{{math.Ceil 2.1}}", "3"},
+			},
+		)
+
 		ns.AddMethodMapping(ctx.Div,
 			[]string{"div"},
 			[][2]string{
@@ -43,6 +50,13 @@
 			},
 		)
 
+		ns.AddMethodMapping(ctx.Floor,
+			nil,
+			[][2]string{
+				{"{{math.Floor 1.9}}", "1"},
+			},
+		)
+
 		ns.AddMethodMapping(ctx.Log,
 			nil,
 			[][2]string{
@@ -68,6 +82,13 @@
 			[]string{"mul"},
 			[][2]string{
 				{"{{mul 2 3}}", "6"},
+			},
+		)
+
+		ns.AddMethodMapping(ctx.Round,
+			nil,
+			[][2]string{
+				{"{{math.Round 1.5}}", "2"},
 			},
 		)