core

package
Version: v2.0.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2017 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HelpInputRune = '?'

	ErrorIcon    = "×"
	HelpIcon     = "ⓘ"
	QuestionIcon = "?"

	MarkedOptionIcon   = "◉"
	UnmarkedOptionIcon = "◯"

	SelectFocusIcon = "❯"
)
View Source
var DisableColor = false
View Source
var ErrorTemplate = `{{color "red"}}   {{ ErrorIcon }} Sorry, your reply was invalid: {{.Error}}{{color "reset"}}
`
View Source
var TemplateFuncs = map[string]interface{}{

	"color": func(color string) string {
		if DisableColor {
			return ""
		}

		switch color {
		case "default":
			return "\033[38;5;61m"
		case "red":
			return "\033[38;5;125m"
		case "gray", "grey":
			return "\033[38;5;102m"
		}

		return ansi.ColorCode(color)
	},
	"HelpInputRune": func() string {
		return string(HelpInputRune)
	},
	"ErrorIcon": func() string {
		return ErrorIcon
	},
	"HelpIcon": func() string {
		return HelpIcon
	},
	"QuestionIcon": func() string {
		return QuestionIcon
	},
	"MarkedOptionIcon": func() string {
		return MarkedOptionIcon
	},
	"UnmarkedOptionIcon": func() string {
		return UnmarkedOptionIcon
	},
	"SelectFocusIcon": func() string {
		return SelectFocusIcon
	},
}

Functions

func RunTemplate

func RunTemplate(tmpl string, data interface{}) (string, error)

func WriteAnswer

func WriteAnswer(t interface{}, name string, v interface{}) (err error)

Types

type Renderer added in v1.1.0

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

func (*Renderer) Error added in v1.1.2

func (r *Renderer) Error(invalid error) error

func (*Renderer) Render added in v1.1.0

func (r *Renderer) Render(tmpl string, data interface{}) error

Notes

Bugs

  • the current implementation might cause weird conflicts if there are two fields with same name that only differ by casing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL