Help talk:Parser functions in templates
logical error
editI 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)
White spaces
editIs 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.
- {{Wikipedia | phoo}} givs: See phoo Wikipedias article - NOK (.../wiki/).
- {{Wikipedia |phoo}} givs: See Wikipedias article - OK (.../wiki/phoo).
- {{Wikipedia |phoo bar}} givs: See bar Wikipedias article - NOK (.../wiki/phoo).
- {{Wikipedia}} givs: See functions in templates Wikipedias article - NOK (../wiki/Parser).
--Petter Källström, 79.136.98.249 23:13, 1 September 2009 (UTC)
parameter specified or not
editOne 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)
Inconsistency → Incomprehensibility
editI can't even figure out what's supposed to happen. There are two examples given with different syntax
- Sample A
{{{1}}}
(no parameter, no pipe) - Sample B
{{{1|}}}
(no parameter, has pipe)
and different outputs for both conditions:
- Sample A
- condition true
Parameter 1 is not defined, or is defined and non-null/non-empty. - condition false
Parameter 1 is null. It contains only empty string(s) or breaking space(s) etc.
- condition true
- Sample B
- condition true
Parameter 1 is defined and non-null/non-empty. - condition false
Parameter 1 is not defined, or is defined but null. It contains only empty string(s) or breaking space(s) etc.
- condition true
But only one result is shown for each sample: the if-true output for Sample A, and the if-false output for Sample B.
If I get the general idea correctly, the presence or absence of the pipe should affect the test. But the paragraph doesn't even say whether parameter 1 is being supplied, and if so whether it's null or blanks only or nonblank or what. --Thnidu (talk) 17:52, 2 October 2012 (UTC)
Max depth of nested #if parser functions.
editI have a rather large set of nested #ifexpr: tests (48 so far, with intent to add another 30), and I have found that it is not returning the correct values for anything that is past the 40th response. Is there a max nest limit of 40 for this function? -- ShoeMaker ( Contributions • Message ) 22:35, 30 December 2012 (UTC)
- After some in depth testing on a wiki running MediaWiki 1.19.1 with ParserFunctions (Version 1.4.1) there is a nesting limit of 40. I managed to rework my template and section it into chunks. There should be a note added to the Help page itself if anyone can confirm this to be true (my personal testing is not proof to me, could be a bug on my wiki). -- ShoeMaker ( Contributions • Message ) 03:32, 31 December 2012 (UTC)
Where is my mistake?
edit{{#if:{{{image}}}|{{|}}[[File:{{{image}}}{{|}}size{{|}}100x100px]]|{{|}} }}
I am trying for 2 hours now, but the part of "true" won't come out as it should be.