util

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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 defines the methods for util to be used as template functions.

func New

func New(d *deps.Deps) *Namespace

Creates a new util Namespace

func (*Namespace) Explode

func (ns *Namespace) Explode(delim, text interface{}) []string

Explode

Breaks a string into array with a delimiter (separator).

Example: {{ explode "," "hello there !" }} Returns: `[hello there !]`

func (*Namespace) Implode

func (ns *Namespace) Implode(glue, slice interface{}) string

Implode

Returns a string from the elements of an array using a glue string to join them together.

Example: {{ slice 1 2 3 | explode "," }} Returns: `[1 2 3]`

func (*Namespace) Len

func (ns *Namespace) Len(i interface{}) int64

Len

Returns the length of a variable according to its type. If the length of the type passed could not be retrieved, it will return `0`.

Example: {{ len "hello" }} Returns: `5`

func (*Namespace) Seq

func (ns *Namespace) Seq(size interface{}) ([]int64, error)

Seq

Creates a sequence of integers.

Example: {{ seq 5 }} Returns: `[1 2 3 4 5]`

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL