Optional
useIf true
(default), replacement takes place only if the passed wikitext has the original template
starting at ParsedTemplate._startIndex and ending (exclusively) at ParsedTemplate._endIndex.
This prevents a nonparsed template in a transclusion-preventing tag from being wrongly replaced
(Wikitext.parseTemplates does not parse templates inside the relevant tags).
const wikitext = '<!--{{Template}}-->\n{{Template}}'; // The second one is parsed
const Wkt = new Wikitext(wikitext);
const Temps = Wkt.parseTemplates(); // Temps[0]: ParsedTemplate, Temps[1]: undefined
const newWikitext1 = Temps[0].replaceIn(wikitext, {with: ''});
const newWikitext2 = Temps[0].replaceIn(wikitext, {with: '', useIndex: false});
console.log(newWikitext1); // '<!--{{Template}}-->', expected result
console.log(newWikitext2); // '<!---->\n{{Template}}', unexpected result
Optional
withReplace the original template with this string.
Default: ParsedTemplate.render(options)
Generated using TypeDoc
Part of the object passed to the second parameter of ParsedTemplate.replaceIn.