Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template.add after= parameter #315

Merged
merged 2 commits into from
Jan 18, 2024
Merged

Conversation

eseiver
Copy link
Contributor

@eseiver eseiver commented Jan 16, 2024

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:

  • Added the 'after' parameter to the Template.add() method.
  • Implemented the logic to insert the new parameter after the specified existing parameter.
  • Created two appropriate test cases to validate the new feature, which are passing successfully.

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
Copy link
Owner

earwig commented Jan 18, 2024

Thanks a lot!

@earwig earwig merged commit e24c6e4 into earwig:main Jan 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants