iterators

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 4 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	RangeKey   = "range"
	BetweenKey = "between"
	UntilKey   = "until"
	GroupByKey = "groupBy"
)

Keys to be used in templates for the functions in this package.

Variables

This section is empty.

Functions

func New

func New() hctx.Map

New returns a map of the helpers within this package.

Types

type Iterator

type Iterator interface {
	Next() interface{}
}

Iterator type can be implemented and used by the `for` command to build loops in templates

func Between

func Between(a, b int) Iterator

Between will iterate up to, but not including `b`

Between(0,10) // 0,1,2,3,4,5,6,7,8,9

func GroupBy

func GroupBy(size int, underlying interface{}) (Iterator, error)

GroupBy creates an iterator of groups or sub-slices of the underlying Array or Slice entered where each group is of length Len(underlying) / size. If Len(underlying) == size it will return an iterator with only a single group.

func Range

func Range(a, b int) Iterator

Range creates an Iterator that will iterate numbers from a to b, including b.

func Until

func Until(a int) Iterator

Until will iterate up to, but not including `a`

Until(3) // 0,1,2

Jump to

Keyboard shortcuts

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