def template_from_str(value, name):
wikicode = mwparserfromhell.parse(value)
- template_list = wikicode.filter_templates(name)
- if len(name) == 0:
+ template_list = [template for template in wikicode.filter_templates(name) if template.name.strip() == name]
+ if len(template_list) == 0:
raise ValueError('No "{}" template was found'.format(name))
if len(template_list) > 1:
raise ValueError('{} "{}" templates were found'.format(len(template_list), name))
def rodelbahnbox_to_template(value):
- return wikibox_to_template(value, RODELBAHNBOX_DICT, RODELBAHNBOX_TEMPLATE_NAME)
+ return wikibox_to_template(value, RODELBAHNBOX_TEMPLATE_NAME, RODELBAHNBOX_DICT)
def rodelbahnbox_from_str(value):