Help talk:Parser functions in templates

From MediaWiki.org
Jump to: navigation, search

[edit] logical error

I think there's a logical error here. It's easiest to see in the table at the bottom. In sample 1, {{{1}}} is true for both being defined and for being not defined. How can it both be defined and not defined? -Khono

I think it is right. If you call {{foo | bar}}, then both {{{1}}} and {{{1|}}} will return "bar" (in template:foo), why the #if statement treat both as true. --79.136.98.249 23:13, 1 September 2009 (UTC)

[edit] White spaces

Is there any parser function that strip leading and tailing white spaces, or one that change them into "%20" or "_"? I try to make a template that includes a link to wikipedia.

--Petter Källström, 79.136.98.249 23:13, 1 September 2009 (UTC)

[edit] parameter specified or not

One way to test whether a parameter was specified in a template call is thus: {{#ifeq:{{{v|}}}|{{{v|-}}}| v was specified (and may be empty) | v was not specified }}

Could an expert please check whether this is true? I find it returns "v was specified (and may be empty)" only when "|v=" or "|v=text" is in the template call code, otherwise "|v" (without any =) returns "v was not specified ". The latter behaviour is unexpected. -84user 18:20, 27 September 2009 (UTC)

I may have misunderstood, but why is the latter behaviour unexpected? When = is missing, v is interpreted as an unnamed parameter, not as parameter v, so parameter v is missing. I believe that is the correct behaviour. Hamilton Abreu 00:09, 24 January 2010 (UTC)
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox