* mwlib http://code.pediapress.com/wiki/wiki
* https://www.mediawiki.org/wiki/Alternative_parsers
"""
-from typing import Optional
+from typing import Optional, Dict, List
from mwparserfromhell.nodes import Template
+def create_template(name: str, args: List[str], kwargs: Optional[Dict[str, str]] = None) -> Template:
+ """Creates a mwparserfromhell template with from a dictionary (string: string)
+
+ :param name: Name of the template
+ :param args: list of unnamed parameters
+ :param kwargs: named parameters
+ """
+ template = Template(name)
+ for i, value in enumerate(args, 1):
+ template.add(str(i), value, False)
+ if kwargs is not None:
+ for key, value in kwargs.items():
+ template.add(key, value, True)
+ return template
+
+
def format_template_table(template: Template, keylen: Optional[int] = None):
"""Reformat the given template to be tabular. The template is modified in-place