Page MenuHomePhabricator

Allow fallback/default values for #vardefine / #vardefineecho
Closed, DeclinedPublic5 Story PointsFeature

Description

See https://www.mediawiki.org/wiki/Extension_talk:Variables/Archive#Default_values_for_vardefine_and_vardefineecho. Basically, instead of requiring {{ #vardefine: var1 | {{ #if: {{{param1|}}} | {{{param1}}} | something else }} }}, it should be possible to just do {{ #vardefine: var1 | {{{param1|}}} | something else }}. Multiple values might be useful, though there were concerns raised in the linked discussion that they might complicate the code too much, in which case just a single value would be fine.

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 13 2018, 3:06 PM
Dinoguy1000 renamed this task from [Variables] Allow fallback/default values for `#vardefine`/`#vardefineecho` to [Variables] Allow fallback/default values for #vardefine / #vardefineecho.Aug 13 2018, 3:06 PM

While this could be easily done, I agree with @Danwe that it adds some complexity that would probably be better suited in a seperate #or: parser function. Such a parser function sounds quite interesting, but is unlikely to be included in ParserFunctions (we can try though) as well as out of scope for Variables. However, I think that the behavior you suggest is quite what I would suspect from a function like that. I'm kind of unsure if we should do this, however I would like to hear about further opinions.

I just created T201878, proposing an #or parser function.

It's worth noting that #var already provides a fallback/default value; in that vein, there is a certain (though probably pretty weak) argument for also providing one on #vardefine and #vardefineecho. This wouldn't preclude the creation of a separate #or parser function, though; instead, only a single fallback could be provided for these functions, and for more complicated cases, #or would allow multiple fallback values. (Of course, once you've got #or, strictly speaking there isn't a need for any fallbacks on #vardefine/#vardefineecho...)

MGChecker triaged this task as Lowest priority.Oct 24 2018, 11:56 PM
MGChecker set the point value for this task to 5.Oct 25 2018, 12:08 AM
MGChecker renamed this task from [Variables] Allow fallback/default values for #vardefine / #vardefineecho to Allow fallback/default values for #vardefine / #vardefineecho.Jan 23 2019, 11:19 PM
MGChecker changed the subtype of this task from "Task" to "Feature Request".Mar 1 2019, 11:35 PM
MGChecker closed this task as Declined.Apr 19 2019, 11:06 PM
Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptApr 19 2019, 11:06 PM