slice

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: 5 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 slices to be used as template functions.

func New

func New(d *deps.Deps) *Namespace

Creates a new slice Namespace

func (*Namespace) Append

func (ns *Namespace) Append(slice, i interface{}) ([]interface{}, error)

Append

Adds and element to the end of the slice.

Example: {{ append (slice "hello" "world" "!") "verbis" }} Returns: `[hello world ! verbis]`

func (*Namespace) First

func (ns *Namespace) First(slice interface{}) (interface{}, error)

First

Retrieves the first element of the slice.

Example: {{ first (slice "hello" "world" "!") }} Returns: `hello`

func (*Namespace) Last

func (ns *Namespace) Last(slice interface{}) (interface{}, error)

Last

Retrieves the last element of the slice.

Example: {{ last (slice "hello" "world" "!") }} Returns: `!`

func (*Namespace) Prepend

func (ns *Namespace) Prepend(slice, i interface{}) ([]interface{}, error)

Prepend

Adds and element to the beginning of the slice.

Example: {{ prepend (slice "hello" "world" "!") "verbis" }} Returns: `[verbis hello world !]`

func (*Namespace) Reverse

func (ns *Namespace) Reverse(slice interface{}) ([]interface{}, error)

Reverse

Reverses the slice.

Example: {{ reverse (slice "hello" "world" "!") }} Returns: `[! world hello]`

func (*Namespace) Slice

func (ns *Namespace) Slice(i ...interface{}) []interface{}

Slice

Creates a slice (array) of passed arguments.

Example: {{ slice "hello" "world" "!" }} Returns: `[hello world !]`

Jump to

Keyboard shortcuts

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