Extension:VariablesLua
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.5.0 (2021-11-23) |
MediaWiki | 1.35+ |
License | MIT License |
Download | GitHub:
<translate> Note:</translate> |
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'). |
The VariablesLua extension provides support for the Variables extension in Lua modules by the Scribunto extension.
- Bugs and Feature Requests
- Issues at GitHub
Usage
Manual: Liquipedia Help
The extension can be loaded in Lua modules by the Scribunto extension like this:
VariablesLua = mw.ext.VariablesLua
Functions
Functions are based on the ones provided by the Variables extension, adding some more utility.
VariablesLua.vardefine
VariablesLua.vardefine( name, value )
Stores the given value under the given name. If the value is nil
, an empty string is stored.
VariablesLua.vardefineecho
VariablesLua.vardefineecho( name, value )
Identical to VariablesLua.vardefine, but returns the value after storing it.
VariablesLua.var
VariablesLua.var( name, default )
Retrieve a variable stored under the given name.
VariablesLua.varexists
VariablesLua.varexists( name )
Checks if a variable exists. Returns a boolean value.
VariablesLua.var_final
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
- Make sure the Variables extension and Scribunto extension are installed.
- <translate> <tvar name=1>Download</tvar> and place the file(s) in a directory called <tvar name=name>
VariablesLua
</tvar> in your <tvar name=ext>extensions/
</tvar> folder.</translate> - <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
wfLoadExtension( 'VariablesLua' );
- 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>
Version history
- 1.0.0
- Initial release.
- 1.1.0
- Fixed
mw.ext.VariablesLua.varexists()
on newer versions of Extension:Variables.
- 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.
- 1.4.1
- Some minor updates, nothing security relevant but can potentially avoid weird edgecases.
- 1.4.2
- Renamed some functions and classes to be in line with the MediaWiki styleguide.
- 1.5.0
- Restored the boolean return value of
mw.ext.VariablesLua.varexists()
.
See also
File:OOjs UI icon information-progressive.svg | <translate> This extension is included in the following wiki farms/hosts and/or packages:</translate>
<translate> This is not an authoritative list.</translate> <translate> Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here.</translate> <translate> Always check with your wiki farms/hosts or bundle to confirm.</translate> |
- Pages with script errors
- Pages with broken file links
- Beta status extensions
- Extensions without an image
- Parser extensions
- Extensions without a compatibility policy
- Extensions with manual MediaWiki version
- MIT licensed extensions
- Extensions in GitHub version control
- ScribuntoExternalLibraries extensions
- All extensions
- Scribunto extensions