FANDOM


Lua-logo-nolabel

Lua is a very versatile programming language that can be used to greatly enhance any template. There are mainly two ways to use Lua in infoboxes: using it to generate the whole infobox or simply generate a part of it. Lua is interpreted by an extension called Scribunto, the FANDOM version of which is a mostly feature-complete fork of the Scribunto core. Lua code is organized inside modules, which reside in the Module namespace. A module can hold multiple functions and data tables.

Lua-based infoboxes

  Main article: Lua infoboxes

An infobox can be created using Fandom's own InfoboxBuilder, which facilitates its creation, or by generating template or HTML code using Scribunto's libraries. InfoboxBuilder was developed as a user-friendly markup to avoid infobox crafters needing to learn Lua's syntax, and is considered feature-complete, though not currently under development. It, like Scribunto, is enabled by default on all wikis.

It may even be possible to interface the lua-based infoboxes and the portable infoboxes.

Lua within infoboxes

Lua functions can be invoked within wikitext templates or by other modules. In fact, calling one module from another is one of the significant reasons to use Lua, as it is faster and more powerful than nested wikitext templates.

Within Portable Infoboxes, Lua functions can make it easier to format or parse text. At present, this is accomplished with invoke statements; future Portable syntax will accomplish the same effect natively inside the design.

Data in Modules

A data module is a "technical" jargon for a place to store information in a way that machines can read them. Some of the benefits of this are:

  • Separating data - This allows data to be easily input or re-used and makes it faster to process related information.
  • Avoiding template limits - If a page is too complex it may not load at all, data modules may improve the performance of some pages (see Lua Templating/Converting)
  • Improving page performance - as noted above.
  • Re-use - data can be re-used in many pages in different ways.

Examples

  Main article: Lua modules
There are many ways to use modules in templates for things such as:

See also

Start a Discussion Discussions about Lua in Templates

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.