replace

package
v16.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 3 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).
	RegisterTemplate(placeholder, template string)

	// RegisterTemplateFunc does the same as RegisterTemplate, but the template
	// is returned by the template function.
	RegisterTemplateFunc(placeholder string, template func() 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.
	Replace(str, placeholder, value string) string
}

func New

func New() Replacer

New returns a Replacer

Jump to

Keyboard shortcuts

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