earwig / mwparserfromhell

A Python parser for MediaWiki wikicode
https://mwparserfromhell.readthedocs.io/
MIT License
741 stars 74 forks source link

Template.add `after=` parameter #315

Closed eseiver closed 7 months ago

eseiver commented 7 months ago

This pull request addresses #281 by introducing a new feature to the Template.add() method. Currently, when inserting a new parameter into a Template, the only option is to place it before an existing parameter. This PR enhances the functionality by adding support for inserting a parameter after an existing parameter, providing users with more flexibility.

Changes made:

Example:

>>> template = mwparserfromhell.parse("{{foo|bar|baz|eggs=spam}}")
>>> template.add("new_param", "value", after="baz")
>>> print(template)
{{foo|bar|baz|new_param=value|eggs=spam}}
earwig commented 7 months ago

Thanks a lot!