如何选择具有模板默认值的页面?

时间:2017-06-11 17:24:28

标签: mediawiki dpl

所以我们有这个模板:

{| class="wikitable"
|-
| [[Saplings]] || ''{{{saplings|Lower}}}'' || [[Sappiness]] || ''{{{sappiness|Lowest}}}''
|-
| [[Matures]] || ''{{{matures|Average}}}'' || [[Effect (Tree)|Effect]] || ''{{{effect|None}}}''
|-
| [[Height]] || ''{{{height|Small}}}'' || [[Growth (Forestry)|Growth]] || ''{{{growth|Light}}}''
|-
| [[Girth]] || ''{{{girth|1}}}x{{{girth|1}}}'' || [[Tolerates]] || ''{{{tolerates| }}}''
|-
| [[Yield]] || ''{{{yield|Lowest}}}'' || [[Fruits]] || ''{{{fruits|None}}}''
|}<noinclude>{{Documentation}}</noinclude>

如您所见,所有字段都有默认值。现在,在实际的页面中,有些人完全不使用默认值(注意,没有'树苗'):

{{Tree-Attributes
| sappiness = Average
| fruits = Crabapple
}}

虽然其他人明​​确包含默认值:

{{Tree-Attributes
| saplings = Lower
| height = Large
| yield = Lowest
| sappiness = Lower
| fruits = none
| girth = 2
}}

使用以下DPL命令,我可以看到所有具有明确“低”值的命令。如何将那些保留为默认值?

{{#dpl:
  |category     = Trees
  |uses         = Template:Tree
  |includematch = ,/saplings\s*=\s*Lower\s*/i
  |include      = {Tree}:name, {Tree-Attributes}:speed
  |table        = class="wikitable",-,Lower
  |tablerow     = ²{P{{!}}%% Sapling{{!}}F}² [[%%]]<span style="display:none;">«nowiki»,«/nowiki»</span>
  |allowcachedresults = true
}}

[顺便说一句,我不知道为什么有一个属性'speed'的引用,当没有定义时......]

1 个答案:

答案 0 :(得分:0)

自我回答:我暂时没有选择这个答案,看看是否有其他人想出更好的东西。

我通过更改

得到了我想要的结果
includematch = ,/saplings\s*=\s*Lower\s*/i

includematch = ,/(saplings\s*=\s*Lower\s*){{!}}(^((?!saplings)(.{{!}}\n))+$)/i
相关问题