Page MenuHomePhabricator

Add #or parser function to ParserFunctions extension
Closed, DuplicatePublicFeature

Description

Feature summary: I would like an {{#or: parser function added to ParserFunctions. ParserPower provides {{#or:}}, where {{#or:{{{1|}}}|default}} replaces {{#if:{{{1|}}}|{{{1}}}|default}}; and you can include more than 2 arguments to the #or, avoiding nesting ifs.

Use case(s)

  • If you want to write {{#if:<!--result of uncached expensive computation, e.g. Cargo or DPL query -->|reuse that result then you'll require two expensive computations. The workaround requires using the variables extension, which would be good to avoid; but {{#or: will simply work.
  • Also used as a simple syntax sugar for {{#if: (which is itself a syntax sugar for {{#ifeq

Benefits: Adding an {{#or: parser function to ParserFunctions will encourage cleaner and more efficient code. Its use cases are broadly varied, and I feel it's just as useful compared to #if as #if is compared to #ifeq.

Event Timeline

Aklapper changed the subtype of this task from "Task" to "Feature Request".Mar 18 2024, 1:23 PM

Thanks for reporting this. For future reference, please use the feature request form (linked from the top of the task creation page) to create feature requests, and fill in the sections in the template. Thanks!

Ah sorry, I didn't notice that option when creating this ticket. Updated it with that template now!

Pppery subscribed.

I don't see why this can't just be a template.