开发者

Conditional table rows with MediaWiki

I'm writing a template that will be used like this:

{{templatename
|var1=foo
|var4=bar
|var14=toot
}}

There will be many variables in the definition, but no article will ever use all variables. I want the template definition to only display the row if the variable was given when the template is used in an article.

Here is what my template definition looks like:

<table>
<caption>'''V-speeds'''</caption>
{{#if:V1|<tr><td>V1<sub>1</sub></td><td>[[V1::{{{V1}}}]]</td></tr>}}
{{#if:V2|<tr><td>V2<sub>2</sub></td><td>[[V2::{{{V2}}}]]</td></tr>}}
{{#if:V3|<tr><td>V3<sub>3</sub></td><td>[[V3::{{{V3}}}]]</td></tr>}}
{{#if:Va|<tr><td>Va<sub>a</sub></td><td>[[Va::{{{Va}}}]]</td></tr>}}
{{#if:Vb|<tr><td>Vb<sub>b</sub></td><td>[[Vb::{{{Vb}}}]]</td></tr>}}
{{#if:Vc|<tr><td>Vc<sub>c</sub></td><td>[[Vc::{{{Vc}开发者_JAVA百科}}]]</td></tr>}}
...

Basically each line is an if statement that checks to see if that variable evaluates to true, if it does, then print out the HTML for the row.

This doesn't seem to work though. For some reason the {#if:}} statements are not being evaluated. Anyone know what I'm doing wrong?


nevermind, I figured it out, the {{#if}} function needs to be separately installed. It's not part of the official mediawiki package.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜