Documentation
¶
Overview ¶
Package replacer provides a string replacement mechanism with custom replace functions and delimiters.
Index ¶
Constants ¶
View Source
const DefaultDelimiter = "$$"
DefaultDelimiter defines the default delimiter.
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.
SetDelimiter(string) // Sets the delimiter.
Replace(string, map[string]string) string // Replaces substrings based on provided key-value pairs.
}
Replacer interface defines methods for setting delimiters and performing replacements.
func WithDelimiter ¶ added in v0.0.33
WithDelimiter returns a new Replacer instance with the specified delimiter.
func WithHooks ¶
func WithHooks(hooks map[string]ReplaceFunc) Replacer
WithHooks returns a new Replacer instance with the specified hooks.
func WithHooksAndDelimiter ¶ added in v0.0.33
func WithHooksAndDelimiter(hooks map[string]ReplaceFunc, delimiter string) Replacer
WithHooksAndDelimiter returns a new Replacer instance with the specified hooks and delimiter.
Click to show internal directories.
Click to hide internal directories.