21,471
edits
(→See also: rm section because it's at the top, feel free to revert me) |
m (Cleanup) |
||
Line 21: | Line 21: | ||
==Using parameters in templates== | ==Using parameters in templates== | ||
{|{{prettytable}} | |||
{| {{ | ! Description | ||
! Template text | |||
! You type… | |||
! You get… | |||
|- | |- | ||
| | | Template with numbered parameters | ||
| | |<pre><nowiki> | ||
<pre><nowiki> | |||
'''A little thank you...'''<br> | '''A little thank you...'''<br> | ||
<small>for {{{1}}}.<br> | <small>for {{{1}}}.<br> | ||
hugs, {{{2}}}</small> | hugs, {{{2}}}</small> | ||
</nowiki></pre> | </nowiki></pre> | ||
|<code><nowiki>{{Thankyou|all|~~~}}</nowiki></code> | |<code><nowiki>{{Thankyou|all|~~~}}</nowiki></code> | ||
| | |{{Thankyou|all|[[User:Someuser|Someuser]]}} | ||
{{Thankyou|all|[[User:Someuser|Someuser]]}} | |||
|- | |- | ||
| | | Template with named parameters | ||
| | |<pre><nowiki> | ||
<pre><nowiki> | |||
'''A little thank you...'''<br> | '''A little thank you...'''<br> | ||
<small>for {{{reason}}}.<br> | <small>for {{{reason}}}.<br> | ||
hugs, {{{signature}}}</small> | hugs, {{{signature}}}</small> | ||
</nowiki></pre> | </nowiki></pre> | ||
|<pre><nowiki>{{Thankyou | |<pre><nowiki>{{Thankyou | ||
|reason=all | |reason=all | ||
|signature=~~~}}</nowiki></pre> | |signature=~~~ | ||
| | }}</nowiki></pre> | ||
{{Thankyou|all|[[User:Someuser|Someuser]]}} | |{{Thankyou|all|[[User:Someuser|Someuser]]}} | ||
|} | |} | ||
You can define parameters in templates either numbered as <code><nowiki>{{{1}}}</nowiki></code> or named <code><nowiki>{{{param}}}</nowiki></code>. | You can define parameters in templates either numbered as <code><nowiki>{{{1}}}</nowiki></code> or named <code><nowiki>{{{param}}}</nowiki></code>. | ||
Line 88: | Line 78: | ||
For example | For example | ||
<div style="display:table; width:auto;"> | <div style="display:table; width:auto;"> | ||
==Advanced | ==Advanced template usage== | ||
We already covered parameters, think of them as variables (temporarily stored data). MediaWiki allows us to look at those variables and check if they even contain anything. What this lets us do is create templates in which only certain parts appear if the data exists within them, for instance in [[:Template:Infobox]] and [[:Template:Final Fantasy VII/Boss]]. | We already covered parameters, think of them as variables (temporarily stored data). MediaWiki allows us to look at those variables and check if they even contain anything. What this lets us do is create templates in which only certain parts appear if the data exists within them, for instance in [[:Template:Infobox]] and [[:Template:Final Fantasy VII/Boss]]. | ||
Line 96: | Line 86: | ||
The {{#if:}} function allows us to test a variable to see if it is empty or not. It returns the first value (value after the first pipe) if it is not empty and the second value (value after the second pipe) if it is. It is used with the syntax: | The {{#if:}} function allows us to test a variable to see if it is empty or not. It returns the first value (value after the first pipe) if it is not empty and the second value (value after the second pipe) if it is. It is used with the syntax: | ||
<pre>{{#if:<variable to test>|<what to display if test is not empty>|<what to display if test is empty>}}</pre> | <pre>{{#if:<variable to test>|<what to display if test is not empty>|<what to display if test is empty>}}</pre> | ||
{| {{prettytable | {|{{prettytable}} | ||
| | |+ Usage of <nowiki>{{#if:}}</nowiki> | ||
|- | |- | ||
! | !You type… | ||
! | !You see… | ||
!Why | !Why? | ||
|- | |- | ||
|<pre>{{#if:{{{1|}}}|not empty|empty}}</pre> | |<pre>{{#if:{{{1|}}}|not empty|empty}}</pre> | ||
Line 127: | Line 117: | ||
|The test parameter was empty, so that was the result. When skipping sections in the middle of the #if construct, you still need the pipes to go to later sections. | |The test parameter was empty, so that was the result. When skipping sections in the middle of the #if construct, you still need the pipes to go to later sections. | ||
|} | |} | ||
===<nowiki>{{#expr:}}</nowiki>=== | ===<nowiki>{{#expr:}}</nowiki>=== | ||
Line 134: | Line 123: | ||
The operands that can be used in <nowiki>{{#expr:}}</nowiki> are listed below. | The operands that can be used in <nowiki>{{#expr:}}</nowiki> are listed below. | ||
{| {{prettytable}} | {|{{prettytable}} | ||
| | |+ Usage of <nowiki>{{#expr:}}</nowiki> | ||
|- | |- | ||
! | ! Operator | ||
! | ! Operation | ||
! | ! Example | ||
|- | |- | ||
|rowspan="2" colspan="2" align="center"| | |rowspan="2" colspan="2" align="center"| None | ||
| | | | ||
<nowiki>{{#expr: 123456789012345}}</nowiki> = {{#expr: 123456789012345}} | <nowiki>{{#expr: 123456789012345}}</nowiki> = {{#expr: 123456789012345}} | ||
Line 263: | Line 252: | ||
|<parameter to compare test to> | |<parameter to compare test to> | ||
|<what to display if test is true> | |<what to display if test is true> | ||
|<what to display if test is false>}}</pre> | |<what to display if test is false> | ||
}}</pre> | |||
{| {{prettytable}} | {|{{prettytable}} | ||
| | |+ Usage of <nowiki>{{#ifeq:}}</nowiki> | ||
|- | |- | ||
! | !You type… | ||
! | !You see… | ||
|- | |- | ||
|<pre>{{#ifeq:+07|007|yes|no}}</pre> | |<pre>{{#ifeq:+07|007|yes|no}}</pre> | ||
Line 283: | Line 273: | ||
|{{#ifeq:{{#expr:7*5+5}}|40|yes|no}} | |{{#ifeq:{{#expr:7*5+5}}|40|yes|no}} | ||
|} | |} | ||
{{Footer Nav|game=StrategyWiki:Guide|prevpage=Tables|nextpage=Preview and save}} | {{Footer Nav|game=StrategyWiki:Guide|prevpage=Tables|nextpage=Preview and save}} | ||
</div> | </div> |