Documentation
¶
Overview ¶
Package replacer provides a string replacement mechanism with custom replace functions and keywords.
Package replacer provides a string replacement mechanism with custom replace functions and keywords.
Index ¶
Constants ¶
View Source
const DefaultKeyword = "$$"
DefaultKeyword defines the default keyword.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReplaceFunc ¶
ReplaceFunc is a function type that accepts a string and returns a replaced string.
type Replacer ¶
type Replacer interface {
AddHook(string, ReplaceFunc) // Adds a new replace hook.
Replace(string, map[string]string) string // Replaces substrings based on provided key-value pairs.
}
Replacer interface defines methods for setting keywords and performing replacements.
type Setting ¶ added in v0.0.38
Setting is the setting of replacer.
func WithHooks ¶
func WithHooks(hooks map[string]ReplaceFunc) Setting
WithHooks returns a new Replacer instance with the specified hooks.
func WithKeyword ¶ added in v0.0.38
WithKeyword returns a new Replacer instance with the specified keyword.
Click to show internal directories.
Click to hide internal directories.