Open main menu

Extension:VariablesLua

MediaWiki extensions manual
OOjs UI icon advanced.svg
VariablesLua
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.4.0 (2018-08-29)
MediaWiki 1.28+
License MIT License
Download
Translate the VariablesLua extension if it is available at translatewiki.net
Check usage and version matrix.

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

Bugs and Feature Requests
Issues at Github

UsageEdit

Manual: Liquipedia Help

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

VariablesLua = mw.ext.VariablesLua

FunctionsEdit

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

VariablesLua.vardefineEdit

VariablesLua.vardefine( name, value )

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

VariablesLua.vardefineechoEdit

VariablesLua.vardefineecho( name, value )

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

VariablesLua.varEdit

VariablesLua.var( name, default )

Retrieve a variable stored under the given name.

VariablesLua.varexistsEdit

VariablesLua.varexists( name )

Checks if a variable exists. Returns a boolean value.

VariablesLua.var_finalEdit

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.

InstallationEdit

  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'VariablesLua' );
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Version historyEdit

1.0.0
  • Initial release.
1.1.0
1.2.0
  • Added argument type checking.
1.2.1
  • Bug fixes.
1.3.0
  • Added mw.ext.VariablesLua.var_table().
1.4.0
  • Removed mw.ext.VariablesLua.var_table() due to changes in Extension:Variables.

See alsoEdit