Jump to content

Help talk:Switch parser function

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by T.vanschaik (talk | contribs) at 20:58, 18 April 2020 (Default and missing Switch variable: new section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconWikipedia Help Low‑importance
WikiProject iconThis page is within the scope of the Wikipedia Help Project, a collaborative effort to improve Wikipedia's help documentation for readers and contributors. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks. To browse help related resources see the Help Menu or Help Directory. Or ask for help on your talk page and a volunteer will visit you there.
LowThis page has been rated as Low-importance on the project's importance scale.

Question

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

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 this template. To let the template function as before, the default option was intended, but did not work correctly. The problem was solved by place 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

{{Testing Start template
{{ #if: {{{Var1|}}} Start If functie
| {{ #switch: {{{Var1|}}} Start switch
| 1 = one First option
| 2 = two Second option
}} End of switch function
| other ELSE 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]