Edge Rewrite
// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a21e1ebafe7a386c

Jump to content

Help talk:Switch parser function

Page contents not supported in other languages.
Add topic
From Wikipedia, the free encyclopedia
Latest comment: 1 month ago by Janezdrilc in topic Maximum number of cases

Question

[edit]

Is there a way to just switch out certain characters in the string? For example, I want to change all hyphens to spaces. How can I do this?  Nixinova  T  C  06:02, 15 May 2018 (UTC)Reply

@Nixinova: This "switch" parser function won't help you with that, but take a look at Template:Replace -- John of Reading (talk) 06:47, 15 May 2018 (UTC)Reply

Default and missing Switch variable

[edit]

In my experience, see: https://nl.wikibooks.org/wiki/Sjabloon:Kolommen2_(variabel), versions dated april 18, 2020, the default value is NOT echoed when the selector is missing from the list of parameters passed to the template.

The situation occurred when a few related templates were combined into the template mentioned above. To let the template function as before (without the selector parameter Var1), the default option was intended, but did not work correctly. The problem was solved by placing the switch in the TRUE branche of an IF THEN ELSE instruction and the original action in the FALSE branche.

{{Testing

{{ #switch: {{{Var1|}}}

| 1 = one

| 2 = two

| other

}}

Calling above template by

AA{{Testing}}BB

Without any parameter resulted in

AABB

Only when the template was altered into

{{TestingStart template
{{ #if: {{{Var1|}}} Start If function
| {{ #switch: {{{Var1|}}}Start switch
| 1 = oneFirst option
| 2 = two Second option
}}End of switch function
| otherELSE part of the if function
}} End of if function
}}End of template

the call now resulted in

AAotherBB

It took some time to figure out what was happening.T.vanschaik (talk) 20:58, 18 April 2020 (UTC)Reply

Maximum number of cases

[edit]

What's the maximum number of cases switch can consist of? Janezdrilc (talk) 15:14, 3 June 2026 (UTC)Reply