Closed RheingoldRiver closed 6 months ago
Works fine for me:
import mwparserfromhell
wikitext = mwparserfromhell.parse("{{ foo | bar }}")
for template in wikitext.filter_templates():
if template.name.matches("foo"):
print("found foo")
hmmm I'm a bit confused what's going on now because it was definitely not saving until I did a find-replace of all of the {{ i
to {{i
but I can't repro this now, so maybe there was some other problem. I'll close this, sorry for the trouble!
With the following code:
If the wiki code is
{{ TemplateName
(i.e. there is a leading space between the braces & the text on the wiki) thenTemplateName
will not match it for this template. Right now I'm thinking the best workaround without side effects is to clone the template, replace the name with itsstr(name).strip()
but I thinkmatches
shouldn't fail here.