replacer

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 1 Imported by: 0

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

func Replace

func Replace(src string, values map[string]string) string

Replace replaces substrings in the source string based on provided key-value pairs.

Types

type ReplaceFunc

type ReplaceFunc func(string) string

ReplaceFunc is a function type that accepts a string and returns a replaced string.

type Replacer

type Replacer interface {
	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 New

func New() Replacer

New returns a new Replacer instance with default settings.

func WithHooks

func WithHooks(hooks map[string]ReplaceFunc) Replacer

WithHooks returns a new Replacer instance with the specified hooks.

Jump to

Keyboard shortcuts

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