package math
import "github.com/gohugoio/hugo/tpl/math"
Package math provides template functions for mathematical operations.
Index ¶
- type Namespace
- func New() *Namespace
- func (ns *Namespace) Add(a, b interface{}) (interface{}, error)
- func (ns *Namespace) Ceil(x interface{}) (float64, error)
- func (ns *Namespace) Counter() uint64
- func (ns *Namespace) Div(a, b interface{}) (interface{}, error)
- func (ns *Namespace) Floor(x interface{}) (float64, error)
- func (ns *Namespace) Log(a interface{}) (float64, error)
- func (ns *Namespace) Max(a, b interface{}) (float64, error)
- func (ns *Namespace) Min(a, b interface{}) (float64, error)
- func (ns *Namespace) Mod(a, b interface{}) (int64, error)
- func (ns *Namespace) ModBool(a, b interface{}) (bool, error)
- func (ns *Namespace) Mul(a, b interface{}) (interface{}, error)
- func (ns *Namespace) Pow(a, b interface{}) (float64, error)
- func (ns *Namespace) Round(x interface{}) (float64, error)
- func (ns *Namespace) Sqrt(a interface{}) (float64, error)
- func (ns *Namespace) Sub(a, b interface{}) (interface{}, error)
Types ¶
type Namespace ¶
type Namespace struct{}
Namespace provides template functions for the "math" namespace.
func New ¶
func New() *Namespace
New returns a new instance of the math-namespaced template functions.
func (*Namespace) Add ¶
Add adds two numbers.
func (*Namespace) Ceil ¶
Ceil returns the least integer value greater than or equal to x.
func (*Namespace) Counter ¶
Counter increments and returns a global counter. This was originally added to be used in tests where now.UnixNano did not have the needed precision (especially on Windows). Note that given the parallel nature of Hugo, you cannot use this to get sequences of numbers, and the counter will reset on new builds.
func (*Namespace) Div ¶
Div divides two numbers.
func (*Namespace) Floor ¶
Floor returns the greatest integer value less than or equal to x.
func (*Namespace) Log ¶
Log returns the natural logarithm of a number.
func (*Namespace) Max ¶
Max returns the greater of two numbers.
func (*Namespace) Min ¶
Min returns the smaller of two numbers.
func (*Namespace) Mod ¶
Mod returns a % b.
func (*Namespace) ModBool ¶
ModBool returns the boolean of a % b. If a % b == 0, return true.
func (*Namespace) Mul ¶
Mul multiplies two numbers.
func (*Namespace) Pow ¶
Pow returns a raised to the power of b.
func (*Namespace) Round ¶
Round returns the nearest integer, rounding half away from zero.
func (*Namespace) Sqrt ¶
Sqrt returns the square root of a number.
func (*Namespace) Sub ¶
Sub subtracts two numbers.
Source Files ¶
- Version
- v0.94.0
- Published
- Mar 10, 2022
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 3 hours ago –
Tools for package owners.