templates

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

https://github.com/docker/cli/blob/master/templates/templates.go

Index

Constants

This section is empty.

Variables

View Source
var HeaderFunctions = template.FuncMap{
	"json": func(v string) string {
		return v
	},
	"split": func(v string, _ string) string {

		return v
	},
	"join": func(v string, _ string) string {

		return v
	},
	"title": func(v string) string {
		return v
	},
	"lower": func(v string) string {
		return v
	},
	"upper": func(v string) string {
		return v
	},
	"truncate": func(v string, _ int) string {
		return v
	},
}

HeaderFunctions are used to created headers of a table. This is a replacement of basicFunctions for header generation because we want the header to remain intact. Some functions like `pad` are not overridden (to preserve alignment with the columns).

Functions

func New

func New(tag string) *template.Template

New creates a new empty template with the provided tag and built-in template functions.

func NewParse

func NewParse(tag, format string) (*template.Template, error)

NewParse creates a new tagged template with the basic functions and parses the given format.

func Parse

func Parse(format string) (*template.Template, error)

Parse creates a new anonymous template with the basic functions and parses the given format.

Types

type TableFormatter

type TableFormatter struct {
}

func NewTableFormatter

func NewTableFormatter() *TableFormatter

func (*TableFormatter) Format

func (f *TableFormatter) Format(columns []string, rows [][]string) error

Jump to

Keyboard shortcuts

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