浏览代码

Update template.py

Made has() and get() case insensitive
pull/236/head
TheSandDoctor 6 年前
committed by GitHub
父节点
当前提交
10301ac6d9
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. +4
    -4
      mwparserfromhell/nodes/template.py

+ 4
- 4
mwparserfromhell/nodes/template.py 查看文件

@@ -203,9 +203,9 @@ class Template(Node):
is empty. Note that a template may have multiple parameters with the
same name, but only the last one is read by the MediaWiki parser.
"""
name = str(name).strip()
name = str(name).strip().lower()
for param in self.params:
if param.name.strip() == name:
if param.name.strip().lower() == name:
if ignore_empty and not param.value.strip():
continue
return True
@@ -223,9 +223,9 @@ class Template(Node):
parameters can have the same name, we'll return the last match, since
the last parameter is the only one read by the MediaWiki parser.
"""
name = str(name).strip()
name = str(name).strip().lower()
for param in reversed(self.params):
if param.name.strip() == name:
if param.name.strip().lower() == name:
return param
raise ValueError(name)



正在加载...
取消
保存