Extension:Lua

What can this extension do?
The Lua parser extensions allow you to embed blocks of Lua code into your pages and templates to be parsed and expanded by MediaWiki.

Traditionally, extensions such as ParserFunctions have offered some degree of programmability to MediaWiki's template system; however, this was not originally its intended purpose, and its syntax and utility have proven to be rather cumbersome and limited. As an alternative approach, this extension brings the full power of the Lua programming language to wikitext - including features such as variables with lexical scoping, data control structures and functions, and mathematical and string processing.

This extension requires either the PHP Lua extension from PECL (preferred) or a standalone Lua interpreter (e.g. from LuaBinaries, or the "lua" package in most modern UNIX-like distributions), be installed to function.

Usage
The  tag is used to embed blocks of Lua code into wikitext, which are then executed. Arguments to the  tag will be available as variables to the embedded code; the standard Lua functions print and io.write may be used to pass output back to the parser.

The  parser function may be used to embed a single Lua expression which will be immediately printed to the parser as if it were wrapped in a   statement; additionally, its contents will be processed by the parser beforehand, unlike the   tag. Its semantics are thus quite similar to the ParserFunctions  function.

All variables and function declarations persist from one block/expression to the next, throughout the page. Complicated expressions and calculations can thus easily be separated from their presentation. For example,

Download instructions
You can download this extension via the MediaWiki extension distribution system, or via Wikimedia SVN.

Installation
This extension may be configured in two separate ways, using either the PHP Lua extension from PECL or a standalone Lua interpreter.

Using the PHP Lua extension from PECL
First, download, compile, and install the "lua" package from PECL.

Then, to install the extension, extract the extension files to your MediaWiki extensions/ folder, add the following to LocalSettings.php:

Using a standalone Lua interpreter
First, download and install the Lua interpreter. Most modern UNIX-like distributions will have this in their repositories under e.g. "lua" or "lua5.1"; precompiled binaries for several operating systems are also available from the LuaBinaries project at LuaForge.

Extract the extension files to your MediaWiki extensions/ folder. Then, assuming your Lua binary is located at, add the following to LocalSettings.php: