Last modified: 2011-03-13 18:04:28 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 18199 - Provide the ternary operator (condition ? then : else)
Provide the ternary operator (condition ? then : else)
Product: MediaWiki extensions
Classification: Unclassified
ParserFunctions (Other open bugs)
All All
: Lowest enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
  Show dependency treegraph
Reported: 2009-03-27 15:40 UTC by René Kijewski
Modified: 2011-03-13 18:04 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

Includes ?: and sgn (3.91 KB, patch)
2009-03-27 15:59 UTC, René Kijewski

Description René Kijewski 2009-03-27 15:40:37 UTC
It would be nice if there would be a ternary operator ([[?:]]) for #expr like the most programming languages have.
I wrote a little patch that would provide this operator. And since it would be needful, I inserted a sign function (e.g. sgn -2 == -1), too.
There are two new messages ("unserved_question_mark" and "missing_question_mark") that need to be added in the i18n.
Comment 1 René Kijewski 2009-03-27 15:59:43 UTC
Created attachment 5966 [details]
Includes ?: and sgn

I forgot to upload the diff ... please read the first post.
Comment 2 Chad H. 2010-01-08 15:00:33 UTC
Suggest WONTFIX. We've turned down proposals to expand programmatic features into ParserFunctions before, and I think this falls under that. 

Could possibly be (if it isn't already) implemented in the Lua extension, and would probably be included in the "one day eventual rewrite of template syntax" we toss around from time to time.
Comment 3 Max Semenik 2010-01-08 15:06:36 UTC
Amen. Additionally, this operator would have been particulary grave offender against readability and clarity for non-programmers.
Comment 4 Platonides 2010-01-08 15:12:40 UTC
You already have #if, #ifeq wich take if and else "branches".

Note You need to log in before you can comment on or make changes to this bug.