User:OrenBochman/Lua MediaWiki Interface


  • {{ #invoke: module_name | function_name |arg1 | arg2 | name1 = value1 }}
  • #invoke instances are isolated, globals defined in one are not available in another
  • Only caches are shared

Module structureEdit

  • A module is a Lua chunk that returns an export


  • require() provided
    • not isolated
  • package library provided

Return ValueEdit

The exported function returns a wikitext string:

  • Multiple return values are concatenated
  • Non-string return values are converted to string
    • Metatable entry "tostring" supported

Frame MethodsEdit

  • Argument access: args
local name1 = frame.args.name1
  • argumentPairs()
local t = {}
for name, value in frame:argumentPairs() do
    t[name] = value
  • getParent()
    • Provides access to the parent frame, i.e. the arguments to the template which called #invoke
  • Wikitext preprocessing
  • Structured template invocation
title = 'template',
args = {foo = foo}}

Trying it it outEdit

local p = {}
function p.hello(frame)
return 'Hello ' .. frame.args[1]
return p