MediaWiki extensions manual
Release status: beta
Implementation Parser extension
Description Provides support for the Variables extension in Lua modules by the Scribunto extension
Author(s) Alex Winkler
Latest version 1.5.0 (2021-11-23)
MediaWiki 1.35+
License MIT License

The VariablesLua extension provides support for the Variables extension in Lua modules by the Scribunto extension.

Bugs and Feature Requests
Issues at GitHub

Usage edit

Manual: Liquipedia Help

The extension can be loaded in Lua modules by the Scribunto extension like this:

VariablesLua = mw.ext.VariablesLua

Functions edit

Functions are based on the ones provided by the Variables extension, adding some more utility.

VariablesLua.vardefine edit

VariablesLua.vardefine( name, value )

Stores the given value under the given name. If the value is nil, an empty string is stored.

VariablesLua.vardefineecho edit

VariablesLua.vardefineecho( name, value )

Identical to VariablesLua.vardefine, but returns the value after storing it.

VariablesLua.var edit

VariablesLua.var( name, default )

Retrieve a variable stored under the given name.

VariablesLua.varexists edit

VariablesLua.varexists( name )

Checks if a variable exists. Returns a boolean value.

VariablesLua.var_final edit

VariablesLua.var_final( name, default )

Returns the last value stored (i.e. the last VariablesLua.vardefine or #vardefine in the code). The value can only be returned and not be used in the Lua code itself.

Installation edit

Version history edit

  • Initial release.
  • Added argument type checking.
  • Bug fixes.
  • Added mw.ext.VariablesLua.var_table().
  • Removed mw.ext.VariablesLua.var_table() due to changes in Extension:Variables.
  • Some minor updates, nothing security relevant but can potentially avoid weird edgecases.
  • Renamed some functions and classes to be in line with the MediaWiki styleguide.
  • Restored the boolean return value of mw.ext.VariablesLua.varexists().

See also edit