UNPKG

@ribajs/core

Version:

Core module of Riba.js

13 lines (11 loc) 391 B
import { Formatter } from "../../types/index.js"; /** * Replaces all occurrences of a string with a substring. * @see https://help.shopify.com/en/themes/liquid/filters/string-filters#replace */ export const replaceFormatter: Formatter = { name: "replace", read(str: string, value: string, replaceValue: string) { return str.replace(new RegExp(value, "g"), replaceValue); }, };