Last modified: 2011-03-13 18:04:28 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.
Created attachment 5966 [details] Includes ?: and sgn I forgot to upload the diff ... please read the first post.
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.
Amen. Additionally, this operator would have been particulary grave offender against readability and clarity for non-programmers.
You already have #if, #ifeq wich take if and else "branches".