template

package
v0.86.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncMap = func() template.FuncMap {
	f := sprig.HermeticTxtFuncMap()
	f["getLastIndex"] = func(collection interface{}) int {
		if v := reflect.ValueOf(collection); v.Kind() == reflect.Slice {
			return v.Len() - 1
		}

		return 0
	}
	f["byMatchName"] = func(collection interface{}) interface{} {
		matches, ok := collection.([]models.Match)
		if !ok {
			return collection
		}

		sort.Sort(models.MatchSort(matches))
		return matches
	}
	return f
}()

FuncMap is a function that returns template.FuncMap with custom functions available to template authors.

Functions

This section is empty.

Types

type Presenter

type Presenter struct {
	// contains filtered or unexported fields
}

Presenter is an implementation of presenter.Presenter that formats output according to a user-provided Go text template.

func NewPresenter

func NewPresenter(pb models.PresenterConfig, templateFile string) *Presenter

NewPresenter returns a new template.Presenter.

func (*Presenter) Present

func (pres *Presenter) Present(output io.Writer) error

Present creates output using a user-supplied Go template.

Jump to

Keyboard shortcuts

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