Documentation ¶
Index ¶
- type Namespace
- func (ns *Namespace) After(index interface{}, seq interface{}) (interface{}, error)
- func (ns *Namespace) Apply(seq interface{}, fname string, args ...interface{}) (interface{}, error)
- func (ns *Namespace) Delimit(seq, delimiter interface{}, last ...interface{}) (template.HTML, error)
- func (ns *Namespace) Dictionary(values ...interface{}) (map[string]interface{}, error)
- func (ns *Namespace) EchoParam(a, key interface{}) interface{}
- func (ns *Namespace) First(limit interface{}, seq interface{}) (interface{}, error)
- func (ns *Namespace) In(l interface{}, v interface{}) bool
- func (ns *Namespace) Index(item interface{}, indices ...interface{}) (interface{}, error)
- func (ns *Namespace) Intersect(l1, l2 interface{}) (interface{}, error)
- func (ns *Namespace) IsSet(a interface{}, key interface{}) (bool, error)
- func (ns *Namespace) KeyVals(key interface{}, vals ...interface{}) (types.KeyValues, error)
- func (ns *Namespace) Last(limit interface{}, seq interface{}) (interface{}, error)
- func (ns *Namespace) Querify(params ...interface{}) (string, error)
- func (ns *Namespace) Seq(args ...interface{}) ([]int, error)
- func (ns *Namespace) Shuffle(seq interface{}) (interface{}, error)
- func (ns *Namespace) Slice(args ...interface{}) []interface{}
- func (ns *Namespace) Sort(seq interface{}, args ...interface{}) (interface{}, error)
- func (ns *Namespace) Union(l1, l2 interface{}) (interface{}, error)
- func (ns *Namespace) Uniq(l interface{}) (interface{}, error)
- func (ns *Namespace) Where(seq, key interface{}, args ...interface{}) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace provides template functions for the "collections" namespace.
func (*Namespace) Apply ¶
Apply takes a map, array, or slice and returns a new slice with the function fname applied over it.
func (*Namespace) Delimit ¶
func (ns *Namespace) Delimit(seq, delimiter interface{}, last ...interface{}) (template.HTML, error)
Delimit takes a given sequence and returns a delimited HTML string. If last is passed to the function, it will be used as the final delimiter.
func (*Namespace) Dictionary ¶
Dictionary creates a map[string]interface{} from the given parameters by walking the parameters and treating them as key-value pairs. The number of parameters must be even.
func (*Namespace) EchoParam ¶
func (ns *Namespace) EchoParam(a, key interface{}) interface{}
EchoParam returns a given value if it is set; otherwise, it returns an empty string.
func (*Namespace) Index ¶
Index returns the result of indexing its first argument by the following arguments. Thus "index x 1 2 3" is, in Go syntax, x[1][2][3]. Each indexed item must be a map, slice, or array.
Copied from Go stdlib src/text/template/funcs.go.
We deviate from the stdlib due to https://github.com/golang/go/issues/14751.
TODO(moorereason): merge upstream changes.
func (*Namespace) Intersect ¶
Intersect returns the common elements in the given sets, l1 and l2. l1 and l2 must be of the same type and may be either arrays or slices.
func (*Namespace) IsSet ¶
IsSet returns whether a given array, channel, slice, or map has a key defined.
func (*Namespace) Querify ¶
Querify encodes the given parameters in URL-encoded form ("bar=baz&foo=quux") sorted by key.
func (*Namespace) Seq ¶
Seq creates a sequence of integers. It's named and used as GNU's seq.
Examples:
3 => 1, 2, 3 1 2 4 => 1, 3 -3 => -1, -2, -3 1 4 => 1, 2, 3, 4 1 -2 => 1, 0, -1, -2
func (*Namespace) Slice ¶
func (ns *Namespace) Slice(args ...interface{}) []interface{}
Slice returns a slice of all passed arguments.
func (*Namespace) Union ¶
Union returns the union of the given sets, l1 and l2. l1 and l2 must be of the same type and may be either arrays or slices. If l1 and l2 aren't of the same type then l1 will be returned. If either l1 or l2 is nil then the non-nil list will be returned.