Extension:ParserPower

From Linux Web Expert

MediaWiki extensions manual
ParserPower
Release status: unknown
Author(s)
Latest version 1.1.0
MediaWiki
License GNU General Public License 2.0 or later
Download
Quarterly downloads Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').

Installation

  • <translate> [[<tvar name=2>Special:ExtensionDistributor/ParserPower</tvar>|Download]] and move the extracted <tvar name=name>ParserPower</tvar> folder to your <tvar name=ext>extensions/</tvar> directory.</translate>
    <translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/ParserPower
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'ParserPower' );
    
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

Usage

ParserPower provides several parser functions, most notably {{#or:param1|param2|param3|...}}, which returns the first nonempty value passed. This can be used as a syntax sugar for {{#if:{{{1|}}}|{{{1}}}|default}}, and if {{{1|}}} is instead a value requiring an expensive computation that won't get cached (e.g. the result of a Cargo query), it provides a Variables-free approach to do the computation only once.

Other parser functions include:

  • {{#follow:page title}}, returning a page's name or its redirect target (expensive the first time it's used on a particular page)
  • {{#arraymap:value | delimiter | variable | formula | new_delimiter | conjunction}} as in Page Forms (will not load if Page Forms is also installed)
  • {{#arraymaptemplate:value | template | delimiter | new_delimiter}} as in Page Forms (will not load if Page Forms is also installed)
  • Several list-handling functions:
    • {{#lstcnt:list|separator}}
    • {{#lstsep:list|input separator|output separator}}
    • {{#lstelem:list|input separator|index}} (1-indexed)
    • {{#lstsub:list|input separator|output separator|start index|length}}
    • {{#lstfnd:item to find|list|separator|case sensitivity option}}
    • {{#lstind:item to find|list|separator|options}}
    • {{#lstapp:list|separator|new item}}
    • {{#lstprep:new item|separator|list}}
    • {{#lstjoin:first list|first input separator|second list|second input separator|output separator}}
    • {{#listfilter:}}
    • {{#lstfltr:items to keep|items separator|list|input separator|output separator|case sensitivity option}}
    • {{#lstrm:item to remove|list|input separator|output separator|case sensitivity option}}
    • {{#lstcntuniq:list|separator|case sensitivity option}}
    • {{#listunique:}}
    • {{#listsort:}}
    • {{#listmap:}}
    • {{#listmerge:}}