Help:Parser functions and conditional values
From semantic-mediawiki.org
| Semantic extension(s): | Semantic MediaWiki · Semantic Scribunto |
| Further extension(s): | ParserFunctions |
| Keyword(s): | parser function · condition |
Description:
MediaWiki is a templating system, not a programming environment. The effect is that all parameters to all parser functions are always evaluated. (If you want a real programming environment, see extension "Semantic_Scribunto"Provides service functions to support the Scribunto extension).
This does not work as expected, because it will set both values:
{{#if: Some condition |{{#set: Property=Yay. }} |{{#set: Property=Nope. }} }}
The correct way to do it is
{{#set: Property={{#if: Some condition |Yay. |Nope. }} }}
For the same reason, this does not work:
{{#ask:
[[Some query condition]]
|intro=Here are the results: {{#set: ResultProperty=INTRO }}
|outro=These were the results! {{#set: ResultProperty=OUTRO }}
|default=There are NO results! {{#set: ResultProperty=DEFAULT }}
}}
Even if the text "There are NO results!" is NOT displayed when there are some results to the query, still the #set parser function gets called.
Further information: