package compare
import "github.com/gohugoio/hugo/tpl/compare"
Package compare provides template functions for comparing values.
Index ¶
- type Namespace
- func New(loc *time.Location, caseInsensitive bool) *Namespace
- func (n *Namespace) Conditional(cond any, v1, v2 any) any
- func (*Namespace) Default(defaultv any, givenv ...any) (any, error)
- func (n *Namespace) Eq(first any, others ...any) bool
- func (n *Namespace) Ge(first any, others ...any) bool
- func (n *Namespace) Gt(first any, others ...any) bool
- func (n *Namespace) Le(first any, others ...any) bool
- func (n *Namespace) Lt(first any, others ...any) bool
- func (n *Namespace) LtCollate(collator *langs.Collator, first any, others ...any) bool
- func (n *Namespace) Ne(first any, others ...any) bool
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace provides template functions for the "compare" namespace.
func New ¶
New returns a new instance of the compare-namespaced template functions.
func (*Namespace) Conditional ¶
Conditional can be used as a ternary operator.
It returns v1 if cond is true, else v2.
func (*Namespace) Default ¶
Default checks whether a givenv is set and returns the default value defaultv 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 ¶
Eq returns the boolean truth of arg1 == arg2 || arg1 == arg3 || arg1 == arg4.
func (*Namespace) Ge ¶
Ge returns the boolean truth of arg1 >= arg2 && arg1 >= arg3 && arg1 >= arg4.
func (*Namespace) Gt ¶
Gt returns the boolean truth of arg1 > arg2 && arg1 > arg3 && arg1 > arg4.
func (*Namespace) Le ¶
Le returns the boolean truth of arg1 <= arg2 && arg1 <= arg3 && arg1 <= arg4.
func (*Namespace) Lt ¶
Lt returns the boolean truth of arg1 < arg2 && arg1 < arg3 && arg1 < arg4.
func (*Namespace) LtCollate ¶
LtCollate returns the boolean truth of arg1 < arg2 && arg1 < arg3 && arg1 < arg4. The provided collator will be used for string comparisons. This is for internal use.
func (*Namespace) Ne ¶
Ne returns the boolean truth of arg1 != arg2 && arg1 != arg3 && arg1 != arg4.
Source Files ¶
- Version
- v0.144.2 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 13 packages
- Last checked
- 7 hours ago –
Tools for package owners.