ReplaceParser
Swap every occurrence of one string for another.
replace takes what to find and what to put in its place, separated by a comma, and rewrites every match in the payload.
For template authors
Syntax
{replace(find,replacement):text}Only the first comma splits the two halves. Everything after it is the replacement, commas included, so you can insert a comma but not search for one.
Examples
Leave the first half empty to insert the replacement between every character:
For developers
Register the parser
import { Interpreter, ReplaceParser } from 'tagscript';
const ts = new Interpreter(new ReplaceParser());Behaviour
Both the parameter and the payload are required. parse calls String.prototype.replaceAll with plain strings, so the search text is literal and never treated as a regular expression. There is no way for a template author to write a pattern that backtracks.
API reference
Last updated on