2020-04-01 20:02:49 +00:00
|
|
|
!! Version 2
|
2008-10-27 17:56:58 +00:00
|
|
|
# Force the test runner to ensure the extension is loaded
|
2020-04-01 20:02:49 +00:00
|
|
|
!! functionhooks
|
|
|
|
time
|
|
|
|
!! endfunctionhooks
|
2008-10-27 17:56:58 +00:00
|
|
|
|
|
|
|
# fixme: #time seems to be accepting input as local time, which strikes me as wrong
|
|
|
|
|
2010-02-13 15:49:05 +00:00
|
|
|
!! article
|
2010-02-15 14:45:33 +00:00
|
|
|
ParserFunctions page
|
2010-02-13 15:49:05 +00:00
|
|
|
!! text
|
2010-02-15 14:45:33 +00:00
|
|
|
A sample page so we can test ifexist.
|
|
|
|
|
|
|
|
This used to be a Main Page, but that caused duplicate article
|
|
|
|
warnings when running the normal tests at the same time.
|
2010-02-13 15:49:05 +00:00
|
|
|
!! endarticle
|
|
|
|
|
2010-02-13 15:08:25 +00:00
|
|
|
!! article
|
|
|
|
File:Dionysos-Brunnen am Kölner Dom.jpg
|
|
|
|
!! text
|
|
|
|
blah blah
|
|
|
|
!! endarticle
|
|
|
|
|
2014-05-22 22:27:23 +00:00
|
|
|
!! article
|
|
|
|
File:Redirect_to_Foobar.jpg
|
|
|
|
!! text
|
|
|
|
#REDIRECT[[File:Foobar.jpg]]
|
|
|
|
!! endarticle
|
|
|
|
|
|
|
|
!! article
|
|
|
|
File:Redirect_to_nowhere.jpg
|
|
|
|
!! text
|
|
|
|
#REDIRECT[[File:Missing target file.jpg]]
|
|
|
|
!! endarticle
|
|
|
|
|
2008-10-27 17:56:58 +00:00
|
|
|
!! test
|
2011-12-07 20:52:41 +00:00
|
|
|
Input times are UTC, not local time
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2008-10-27 17:56:58 +00:00
|
|
|
{{#time:c|15 January 2001}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2008-10-27 17:56:58 +00:00
|
|
|
<p>2001-01-15T00:00:00+00:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Time test in traditional range...
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2008-10-27 17:56:58 +00:00
|
|
|
{{#time:Y|15 January 2001}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2008-10-27 17:56:58 +00:00
|
|
|
<p>2001
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Time test prior to 1970 Unix creation myth
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2008-10-27 17:56:58 +00:00
|
|
|
{{#time:Y|5 April 1967}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2008-10-27 17:56:58 +00:00
|
|
|
<p>1967
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Time test after the 2038 32-bit Apocalype
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2008-10-27 17:56:58 +00:00
|
|
|
{{#time:Y|28 July 2061}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2008-10-27 17:56:58 +00:00
|
|
|
<p>2061
|
|
|
|
</p>
|
|
|
|
!! end
|
2009-06-05 16:53:59 +00:00
|
|
|
|
2011-12-07 20:52:41 +00:00
|
|
|
!! test
|
|
|
|
Explicitly specified timezone: UTC
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2011-12-07 20:52:41 +00:00
|
|
|
{{#time:Y-m-d H:i| 2011-11-12 23:00 UTC }}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2011-12-07 20:52:41 +00:00
|
|
|
<p>2011-11-12 23:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Explicitly specified timezone: Europe/Paris (UTC+1)
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2011-12-07 20:52:41 +00:00
|
|
|
{{#time:Y-m-d H:i| 2011-11-12 23:00 Europe/Paris }}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2011-12-07 20:52:41 +00:00
|
|
|
<p>2011-11-12 22:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Explicitly specified timezone: America/New_York (UTC-5)
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2011-12-07 20:52:41 +00:00
|
|
|
{{#time:Y-m-d H:i| 2011-11-12 23:00 America/New_York }}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2011-12-07 20:52:41 +00:00
|
|
|
<p>2011-11-13 04:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2011-12-21 21:59:38 +00:00
|
|
|
!! test
|
2024-07-11 06:28:32 +00:00
|
|
|
Explicitly specified output language (Dutch)
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2011-12-21 21:59:38 +00:00
|
|
|
{{#time:d F Y|1988-02-28|nl}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2011-12-21 21:59:38 +00:00
|
|
|
<p>28 februari 1988
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2024-07-12 01:16:12 +00:00
|
|
|
!! test
|
|
|
|
#timel: UTC
|
|
|
|
!! wikitext
|
|
|
|
{{#timel: Y-m-d H:i | 15 January 2001}}
|
|
|
|
!! html
|
|
|
|
<p>2001-01-15 00:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#timel: Melbourne
|
|
|
|
!! options
|
|
|
|
wgLocaltimezone=Australia/Melbourne
|
|
|
|
!! wikitext
|
|
|
|
{{#timel: Y-m-d H:i | 16 January 2001}}
|
|
|
|
!! html
|
|
|
|
<p>2001-01-16 11:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2024-07-11 06:28:32 +00:00
|
|
|
!! test
|
|
|
|
#timef: one parameter
|
|
|
|
!! wikitext
|
|
|
|
{{#timef:15 January 2001}}
|
|
|
|
!! html
|
|
|
|
<p>00:00, 15 January 2001
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#timef: date only
|
|
|
|
!! wikitext
|
|
|
|
{{#timef:15 January 2001|date}}
|
|
|
|
!! html
|
|
|
|
<p>15 January 2001
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#timef: time only
|
|
|
|
!! wikitext
|
|
|
|
{{#timef:15 January 2001|time}}
|
|
|
|
!! html
|
|
|
|
<p>00:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#timef: "pretty" format
|
|
|
|
!! wikitext
|
|
|
|
{{#timef:15 January 2001|pretty}}
|
|
|
|
!! html
|
|
|
|
<p>15 January
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#timef: Japanese target language
|
|
|
|
!! options
|
|
|
|
language=ja
|
|
|
|
!! wikitext
|
|
|
|
{{#timef:15 January 2001}}
|
|
|
|
!! html
|
|
|
|
<p>2001年1月15日 (月) 00:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#timef: ja parameter
|
|
|
|
!! wikitext
|
|
|
|
{{#timef:15 January 2001|both|ja}}
|
|
|
|
!! html
|
|
|
|
<p>2001年1月15日 (月) 00:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
2024-07-12 01:16:12 +00:00
|
|
|
#timefl: one parameter
|
|
|
|
!! options
|
|
|
|
wgLocaltimezone=Australia/Melbourne
|
2024-07-11 06:28:32 +00:00
|
|
|
!! wikitext
|
2024-07-12 01:16:12 +00:00
|
|
|
{{#timefl:17 January 2001}}
|
2024-07-11 06:28:32 +00:00
|
|
|
!! html
|
2024-07-12 01:16:12 +00:00
|
|
|
<p>11:00, 17 January 2001
|
2024-07-11 06:28:32 +00:00
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2022-11-03 17:30:49 +00:00
|
|
|
!! test
|
|
|
|
#titleparts
|
|
|
|
!! wikitext
|
|
|
|
{{#titleparts:A/b/c/d}}
|
|
|
|
{{#titleparts:A/b/c/d|1}}
|
|
|
|
{{#titleparts:A/b/c/d|2}}
|
|
|
|
{{#titleparts:A/b/c/d|-3}}
|
|
|
|
{{#titleparts:A/b/c/d||1}}
|
|
|
|
{{#titleparts:A/b/c/d||2}}
|
|
|
|
{{#titleparts:A/b/c/d||-2}}
|
|
|
|
{{#titleparts:A/b/c/d|1|1}}
|
|
|
|
{{#titleparts:A/b/c/d|1|2}}
|
|
|
|
{{#titleparts:A/b/c/d|1|-2}}
|
|
|
|
!! html
|
|
|
|
<p>A/b/c/d
|
|
|
|
A
|
|
|
|
A/b
|
|
|
|
A
|
|
|
|
A/b/c/d
|
|
|
|
b/c/d
|
|
|
|
c/d
|
|
|
|
A
|
|
|
|
b
|
|
|
|
c
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#titleparts stops splitting after 25 parts
|
|
|
|
!! wikitext
|
|
|
|
{{#titleparts:A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/!|24}}
|
|
|
|
{{#titleparts:A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/!|25}}
|
|
|
|
{{#titleparts:A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/!|-1}}
|
|
|
|
{{#titleparts:A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/!||-1}}
|
|
|
|
!! html
|
|
|
|
<p>A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x
|
|
|
|
A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/!
|
|
|
|
A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x
|
|
|
|
!/!/!
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2022-12-16 08:49:11 +00:00
|
|
|
!! test
|
|
|
|
Zero parameters in #if and such
|
|
|
|
!! wikitext
|
|
|
|
[{{#ifexpr:}},{{#if:}},{{#ifeq:}},{{#switch:}},{{#ifexist:}}]
|
|
|
|
!! html
|
|
|
|
<p>[,,,,]
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Empty condition in #if and such
|
|
|
|
!! wikitext
|
|
|
|
Empty ifexpr is {{#ifexpr:|true|false}}
|
|
|
|
Empty if is {{#if:|true|false}}
|
|
|
|
Empty ifeq is {{#ifeq:||equal|not equal}}
|
|
|
|
Empty switch is {{#switch:|=empty|#default=something else}}
|
|
|
|
Empty ifexist is {{#ifexist:|true|false}}
|
|
|
|
!! html
|
|
|
|
<p>Empty ifexpr is false
|
|
|
|
Empty if is false
|
|
|
|
Empty ifeq is equal
|
|
|
|
Empty switch is empty
|
|
|
|
Empty ifexist is false
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Missing or all-empty outputs
|
|
|
|
!! wikitext
|
|
|
|
[{{#ifexpr: 1}},{{#ifexpr: 1|}},{{#ifexpr: 1||}}]
|
|
|
|
[{{#if: 1}},{{#if: 1|}},{{#if: 1||}}]
|
|
|
|
[{{#ifeq: 1|1}},{{#ifeq: 1|1|}},{{#ifeq: 1|1||}}]
|
|
|
|
[{{#switch: 1}},{{#switch: 1|}}]
|
|
|
|
[{{#ifexist: ParserFunctions page}},{{#ifexist: ParserFunctions page|}},{{#ifexist: ParserFunctions page||}}]
|
|
|
|
!! html
|
|
|
|
<p>[,,]
|
|
|
|
[,,]
|
|
|
|
[,,]
|
|
|
|
[,]
|
|
|
|
[,,]
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2012-11-08 18:38:55 +00:00
|
|
|
!! test
|
|
|
|
Preserve tags in #switch default value
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2012-11-08 18:38:55 +00:00
|
|
|
{{#switch:a|b|<div>c</div>}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2012-11-08 18:38:55 +00:00
|
|
|
<div>c</div>
|
|
|
|
!! end
|
|
|
|
|
2009-06-05 16:53:59 +00:00
|
|
|
!! test
|
|
|
|
Bug 19093: Default values don't fall through in switch
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2009-06-05 16:53:59 +00:00
|
|
|
<{{#switch: foo | bar | #default = DEF }}>
|
|
|
|
<{{#switch: foo | #default | bar = DEF }}>
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2009-06-05 16:53:59 +00:00
|
|
|
<p><DEF>
|
|
|
|
<DEF>
|
|
|
|
</p>
|
|
|
|
!! end
|
2010-02-13 15:08:25 +00:00
|
|
|
|
|
|
|
!! test
|
|
|
|
{{#ifexist}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2010-02-13 15:08:25 +00:00
|
|
|
{{#ifexist:Media:Foobar.jpg|Found|Not found}}
|
2010-02-15 14:45:33 +00:00
|
|
|
{{#ifexist:ParserFunctions page|Found|Not found}}
|
2010-02-13 15:08:25 +00:00
|
|
|
{{#ifexist:Missing|Found|Not found}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2010-02-13 15:08:25 +00:00
|
|
|
<p>Found
|
|
|
|
Found
|
|
|
|
Not found
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2014-05-22 22:27:23 +00:00
|
|
|
!! test
|
|
|
|
{{#ifexist:}} media redirect (bug 32031)
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2014-05-22 22:27:23 +00:00
|
|
|
{{#ifexist:Media:Redirect_to_Foobar.jpg|Found|Not found}}
|
|
|
|
{{#ifexist:Media:Redirect_to_nowhere.jpg|Found|Not found}}
|
|
|
|
{{#ifexist:Media:Missing file.jpg|Found|Not found}}
|
|
|
|
{{#ifexist:Media:Dionysos-Brunnen am Kölner Dom.jpg|Found|Not found}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2014-05-22 22:27:23 +00:00
|
|
|
<p>Found
|
|
|
|
Not found
|
|
|
|
Not found
|
|
|
|
Not found
|
|
|
|
</p>
|
|
|
|
!!end
|
|
|
|
|
2010-02-13 15:49:05 +00:00
|
|
|
!! test
|
|
|
|
#if
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2010-02-13 15:49:05 +00:00
|
|
|
{{#if: | yes | no}}
|
|
|
|
{{#if: string | yes | no}}
|
|
|
|
{{#if: | yes | no}}
|
|
|
|
{{#if:
|
|
|
|
|
|
|
|
|
|
|
|
| yes | no}}
|
|
|
|
{{#if: 1==2 | yes | no}}
|
|
|
|
{{#if: foo | yes }}
|
|
|
|
{{#if: | yes }}(empty)
|
|
|
|
{{#if: foo | | no}}(empty)
|
|
|
|
{{#if: {{{1}}} | yes | no}}
|
|
|
|
{{#if: {{{1|}}} | yes | no}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2010-02-13 15:49:05 +00:00
|
|
|
<p>no
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
no
|
|
|
|
yes
|
|
|
|
yes
|
|
|
|
(empty)
|
|
|
|
(empty)
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#ifeq
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2010-02-13 15:49:05 +00:00
|
|
|
{{#ifeq: 01 | 1 | yes | no}}
|
|
|
|
{{#ifeq: 0 | -0 | yes | no}}
|
|
|
|
{{#ifeq: foo | bar | yes | no}}
|
|
|
|
{{#ifeq: foo | Foo | yes | no}}
|
|
|
|
{{#ifeq: "01" | "1" | yes | no}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2010-02-13 15:49:05 +00:00
|
|
|
<p>yes
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
no
|
|
|
|
no
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2014-02-15 03:26:30 +00:00
|
|
|
!! test
|
|
|
|
#ifeq entities
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2014-02-15 03:26:30 +00:00
|
|
|
{{#ifeq: {{PAGENAME:*foo&bar}} | *foo&bar | yes | no}}
|
|
|
|
{{#ifeq: a'b | a'b | yes | no}}
|
|
|
|
{{#ifeq: a'b | a&#39;b | yes | no}}
|
|
|
|
{{#ifeq: foo | Foo | *yes | *no}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2014-02-15 03:26:30 +00:00
|
|
|
<p>yes
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
</p>
|
|
|
|
<ul><li>no</li></ul>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
|
2010-02-13 15:49:05 +00:00
|
|
|
!! test
|
|
|
|
#iferror
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2010-02-13 15:49:05 +00:00
|
|
|
{{#iferror: {{#expr: 1 + 2 }} | error | correct }}
|
|
|
|
{{#iferror: {{#expr: 1 + X }} | error | correct }}
|
|
|
|
{{#iferror: {{#expr: 1 + 2 }} | error }}
|
|
|
|
{{#iferror: {{#expr: 1 + X }} | error }}
|
|
|
|
{{#iferror: {{#expr: 1 + 2 }} }}
|
|
|
|
{{#iferror: {{#expr: 1 + X }} }}empty
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2010-02-13 15:49:05 +00:00
|
|
|
<p>correct
|
|
|
|
error
|
|
|
|
3
|
|
|
|
error
|
|
|
|
3
|
|
|
|
empty
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#ifexpr
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2010-02-13 15:49:05 +00:00
|
|
|
{{#ifexpr: | yes | no}}
|
|
|
|
{{#ifexpr: 1 > 0 | yes }}
|
|
|
|
{{#ifexpr: 1 < 0 | yes }}empty
|
|
|
|
{{#ifexpr: 1 > 0 | | no}}empty
|
|
|
|
{{#ifexpr: 1 < 0 | | no}}
|
|
|
|
{{#ifexpr: 1 > 0 }}empty
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2010-02-13 15:49:05 +00:00
|
|
|
<p>no
|
|
|
|
yes
|
|
|
|
empty
|
|
|
|
empty
|
|
|
|
no
|
|
|
|
empty
|
|
|
|
</p>
|
|
|
|
!! end
|
2010-03-18 16:31:51 +00:00
|
|
|
|
|
|
|
!! test
|
|
|
|
Bug 22866: #ifexpr should evaluate "-0" as false
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2010-03-18 16:31:51 +00:00
|
|
|
{{#ifexpr: (-1)*0 | true | false }}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2010-03-18 16:31:51 +00:00
|
|
|
<p>false
|
|
|
|
</p>
|
|
|
|
!! end
|
2012-11-08 22:30:33 +00:00
|
|
|
|
|
|
|
!! test
|
|
|
|
Templates: Parser functions don't strip whitespace from positional parameters
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2012-11-08 22:30:33 +00:00
|
|
|
{{#if: {{foo}}
|
|
|
|
| no-pre-then
|
|
|
|
| no-pre-else
|
|
|
|
}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2012-11-08 22:30:33 +00:00
|
|
|
<p>no-pre-then
|
|
|
|
</p>
|
|
|
|
!! end
|
2014-02-15 03:26:30 +00:00
|
|
|
|
|
|
|
!! test
|
|
|
|
#switch
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2014-02-15 03:26:30 +00:00
|
|
|
{{#switch:foo&bar|foo&bar=yes|no}}
|
|
|
|
{{#switch:foo&bar|fred=1|foo&bar|g=yes|no}}
|
|
|
|
{{#switch:foo&bar|fred=1|foo&'bar|g=yes|no}}
|
|
|
|
{{#switch:foo|bar|baz=no|*default}}
|
|
|
|
{{#switch:none|foo=1|bar=2|#default=no match|baz=3}}
|
|
|
|
{{#switch:none|foo=1|bar=2|#default=ignored|baz=3|Second default}}
|
|
|
|
{{#switch:|a&#39;b}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2014-02-15 03:26:30 +00:00
|
|
|
<p>yes
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
</p>
|
|
|
|
<ul><li>default</li></ul>
|
|
|
|
<p>no match
|
|
|
|
Second default
|
|
|
|
a&#39;b
|
|
|
|
</p>
|
|
|
|
!!end
|
2013-10-05 01:49:54 +00:00
|
|
|
|
|
|
|
!! test
|
|
|
|
#switch #default should match next and not last named parameter
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2013-10-05 01:49:54 +00:00
|
|
|
<{{#switch: foo | #default | bar = DEF }}>
|
|
|
|
<{{#switch: foo | #default | bar = DEF | baz = GHI }}>
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2013-10-05 01:49:54 +00:00
|
|
|
<p><DEF>
|
|
|
|
<DEF>
|
|
|
|
</p>
|
|
|
|
!! end
|
2014-07-11 18:14:36 +00:00
|
|
|
|
|
|
|
!! test
|
|
|
|
#switch should not match #default as a prefix
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2014-07-11 18:14:36 +00:00
|
|
|
<{{#switch: foo | #defaultWTF? = This is crazy }}>
|
|
|
|
<{{#switch: foo | #defaultWTF? | bar = This is crazy }}>
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2014-07-11 18:14:36 +00:00
|
|
|
<p><>
|
|
|
|
<>
|
|
|
|
</p>
|
|
|
|
!! end
|
2016-03-14 18:29:20 +00:00
|
|
|
|
|
|
|
!! test
|
|
|
|
#switch Test php truthy
|
2020-04-01 20:02:49 +00:00
|
|
|
!! wikitext
|
2016-03-14 18:29:20 +00:00
|
|
|
{{#switch: 01 | 1 = yes | no}}
|
|
|
|
{{#switch: 0 | -0 = yes | no}}
|
|
|
|
{{#switch: foo | bar = yes | no}}
|
|
|
|
{{#switch: foo | Foo = yes | no}}
|
|
|
|
{{#switch: "01" | "1" = yes | no}}
|
|
|
|
{{#switch: 1 | 02 | 01 = yes | no}}
|
|
|
|
{{#switch: 1 | "01" | "1" = yes | no}}
|
2020-04-01 20:02:49 +00:00
|
|
|
!! html
|
2016-03-14 18:29:20 +00:00
|
|
|
<p>yes
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
no
|
|
|
|
no
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
</p>
|
|
|
|
!! end
|