replace

package
v16.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Replacer

type Replacer interface {
	// RegisterTemplate registers a template for a specific placeholder. Template
	// may contain placeholders as well of the form {name}. They will be replaced
	// by the parameters of the placeholder (see Replace). If a parameter is not of
	// a template is not present, default values can be provided.
	RegisterTemplate(placeholder, template string, defaults map[string]string)

	// RegisterTemplateFunc does the same as RegisterTemplate, but the template
	// is returned by the template function.
	RegisterTemplateFunc(placeholder string, template TemplateFn, defaults map[string]string)

	// Replace replaces all occurences of placeholder in str with value. The placeholder is of the
	// form {placeholder}. It is possible to escape a characters in value with \\ by appending a ^
	// and the character to escape to the placeholder name, e.g. {placeholder^:} to escape ":".
	// A placeholder may also have parameters of the form {placeholder,key1=value1,key2=value2}.
	// If the value has placeholders itself (see RegisterTemplate), they will be replaced by
	// the value of the corresponding key in the parameters.
	// If the value is an empty string, the registered templates will be searched for that
	// placeholder. If no template is found, the placeholder will be replaced by the empty string.
	// A placeholder name may consist on of the letters a-z and ':'. The placeholder may contain
	// a glob pattern to find the appropriate template.
	Replace(str, placeholder, value string, vars map[string]string, config *app.Config, section string) string
}

func New

func New() Replacer

New returns a Replacer

type TemplateFn added in v16.12.0

type TemplateFn func(config *app.Config, section string) string

Jump to

Keyboard shortcuts

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