hugo: github.com/gohugoio/hugo/tpl/compare Index | Files

package compare

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

Package compare provides template functions for comparing values.

Index

Package Files

compare.go init.go

type Namespace Uses

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

Namespace provides template functions for the "compare" namespace.

func New Uses

func New(caseInsensitive bool) *Namespace

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

func (*Namespace) Conditional Uses

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 Uses

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 Uses

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

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

func (*Namespace) Ge Uses

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

Ge returns the boolean truth of arg1 >= arg2 && arg1 >= arg3 && arg1 >= arg4.

func (*Namespace) Gt Uses

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

Gt returns the boolean truth of arg1 > arg2 && arg1 > arg3 && arg1 > arg4.

func (*Namespace) Le Uses

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

Le returns the boolean truth of arg1 <= arg2 && arg1 <= arg3 && arg1 <= arg4.

func (*Namespace) Lt Uses

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

Lt returns the boolean truth of arg1 < arg2 && arg1 < arg3 && arg1 < arg4.

func (*Namespace) Ne Uses

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

Ne returns the boolean truth of arg1 != arg2 && arg1 != arg3 && arg1 != arg4.

Package compare imports 8 packages (graph) and is imported by 87 packages. Updated 2020-02-18. Refresh now. Tools for package owners.