generic

package
v1.0.0-...-e3b73d2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 8 Imported by: 4

Documentation

Overview

Package generic introduces configurable generic renderer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Renderer

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

Renderer implements generic configurable template renderer. Underlying pool is used for pooling string buffers and make the renderer thread safe.

func NewRenderer

func NewRenderer(style decorate.Style) *Renderer

NewRenderer constructs the instance of generic renderer with the decoration style given.

func (*Renderer) Len

func (rndr *Renderer) Len(tpl string) int

Len returns the length of the text the user see in terminal.

func (*Renderer) Lenf

func (rndr *Renderer) Lenf(tpl string, args ...interface{}) int

Lenf calculates and return the length of the formatted template.

func (*Renderer) MustPrepare

func (rndr *Renderer) MustPrepare(tpl string) (pt prepared.Template)

MustPrepare prerenders the template and panics in case of parsing error.

func (*Renderer) MustRender

func (rndr *Renderer) MustRender(tpl string) string

MustRender renders the template and panics in case of error.

func (*Renderer) MustRenderf

func (rndr *Renderer) MustRenderf(tpl string, args ...interface{}) string

MustRenderf formats and renders the template and panics in case of error.

func (*Renderer) Prepare

func (rndr *Renderer) Prepare(tpl string) (prepared.Template, error)

Prepare prerenders the template given.

func (*Renderer) Render

func (rndr *Renderer) Render(tpl string) (string, error)

Render renders the template given.

func (*Renderer) Renderf

func (rndr *Renderer) Renderf(tpl string, args ...interface{}) (string, error)

Renderf formats and renders the template given.

func (*Renderer) Validate

func (rndr *Renderer) Validate(tpl string) error

Validate validates the template.

Jump to

Keyboard shortcuts

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