The name of the placeholder
The parameters of the placeholder
The type of the placeholder's value
Optional
options: { Options for the placeholder
Optional
braceThe type of braces to use
Optional
global?: booleanWhether to match globally
A RegExp matching a placeholder container
Using a container to match a placeholder and extract its value
const placeholderRegex = Container("myPlaceholder", [], InnerText());
const myPlaceholder = PLCreator.newPlaceholder("myPlaceholder", {
regex: placeholderRegex,
apply_fn: async (str, context) => {
const matches = str.match(new RegExp(placeholderRegex.source));
return { result: matches?.[3] || "" }
}
})
const result = await PLApplicator.bulkApply("{{myPlaceholder:hello, world!}}", { customPlaceholders: [myPlaceholder] })
console.log(result) // hello, world!
Generated using TypeDoc
Constructs a regex for a placeholder container in the format {{name parameter1 parameter2 ... parameterN}}:value}}