package compare

import "github.com/gohugoio/hugo/tpl/compare"

Package compare provides template functions for comparing values.

Package compare provides template functions for comparing values.

Index

Types

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace provides template functions for the "compare" namespace.

func New

func New(caseInsensitive bool) *Namespace

New returns a new instance of the compare-namespaced template functions.

func (*Namespace) And

func (*Namespace) And(arg0 reflect.Value, args ...reflect.Value) reflect.Value

And computes the Boolean AND of its arguments, returning the first false argument it encounters, or the last argument.

func (*Namespace) Conditional

func (n *Namespace) Conditional(condition bool, a, b interface{}) interface{}

Conditional can be used as a ternary operator. It returns a if condition, else b.

func (*Namespace) Default

func (*Namespace) Default(dflt interface{}, given ...interface{}) (interface{}, error)

Default checks whether a given value is set and returns a default value if it is not. "Set" in this context means non-zero for numeric types and times; non-zero length for strings, arrays, slices, and maps; any boolean or struct value; or non-nil for any other types.

func (*Namespace) Eq

func (n *Namespace) Eq(first interface{}, others ...interface{}) bool

Eq returns the boolean truth of arg1 == arg2 || arg1 == arg3 || arg1 == arg4.

func (*Namespace) Ge

func (n *Namespace) Ge(a, b interface{}) bool

Ge returns the boolean truth of arg1 >= arg2.

func (*Namespace) Gt

func (n *Namespace) Gt(a, b interface{}) bool

Gt returns the boolean truth of arg1 > arg2.

func (*Namespace) Le

func (n *Namespace) Le(a, b interface{}) bool

Le returns the boolean truth of arg1 <= arg2.

func (*Namespace) Lt

func (n *Namespace) Lt(a, b interface{}) bool

Lt returns the boolean truth of arg1 < arg2.

func (*Namespace) Ne

func (n *Namespace) Ne(x, y interface{}) bool

Ne returns the boolean truth of arg1 != arg2.

func (*Namespace) Not

func (*Namespace) Not(arg reflect.Value) bool

Not returns the Boolean negation of its argument.

func (*Namespace) Or

func (*Namespace) Or(arg0 reflect.Value, args ...reflect.Value) reflect.Value

Or computes the Boolean OR of its arguments, returning the first true argument it encounters, or the last argument.

Source Files

compare.go init.go truth.go

Version
v0.60.1
Published
Nov 29, 2019
Platform
js/wasm
Imports
9 packages
Last checked
30 minutes ago

Tools for package owners.