From b87f4eef8f3320bf93a638b6b0c536a9fb3daa2e Mon Sep 17 00:00:00 2001 From: AntiCompositeNumber Date: Wed, 19 Aug 2020 00:58:05 -0400 Subject: [PATCH] nodes: Add __contains__ to Template This allows the use of `key in Template` syntax --- mwparserfromhell/nodes/template.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mwparserfromhell/nodes/template.py b/mwparserfromhell/nodes/template.py index 9de7641..1163201 100644 --- a/mwparserfromhell/nodes/template.py +++ b/mwparserfromhell/nodes/template.py @@ -214,6 +214,9 @@ class Template(Node): """Alias for :meth:`has`.""" return self.has(name, ignore_empty) + def __contains__(self, name): + return self.has(name) + def get(self, name, default=_UNSET): """Get the parameter whose name is *name*.