Vikipedio:Lua/Moduloj/LuaWiki/en
Aspekto
Ŝablona programado | Diskutoj | Lua | Testoj | Subpaĝoj | ||||
---|---|---|---|---|---|---|---|---|
Modulo | Esperanto | English | Deutsch
|
Modulo: | Dokumentado |
LuaWiki
– Module with functions for Lua programming in context of a Wiki project.
Functions for templates
[redakti fonton]No direct usage by templates.
Functions for Lua modules (API)
[redakti fonton]Transclusion into own module via require()
as follows:
local LuaWiki = require( "Module:LuaWiki" )
if type( LuaWiki ) == "table" then
LuaWiki.setFrame( frame )
else
-- appropriate error management; e.g. message within functions for templates
end
Thereafter the functions can be accessed; do not forget initialization.
- LuaWiki.getArg( arg, assign )
- Retrieve template argument
arg
– string or number; argument identifierassign
– optional; default value of any type, if not provided in template transclusion- Returns: string (ensured) or default value orherwise
- If not set in template transclusion and no default value, then:
{{{<
arg>}}}
- LuaWiki.getVariable( seek, numeric )
- Retrieve item from wikiVariables; populate if not yet present; see Help:Variablen
seek
– string; name of variable, like"PAGENAME"
numeric
– boolean, optional; true: seek is numeric (else string)- Returns: string or number
- Previous initialization with initVariables accelerates but ist not mandatory.
- LuaWiki.initVariables( request )
- Initialization of some required variables for acceleration
request
– table; selection of variables- every element either:
- string; name of variable, like
"PAGENAME"
- table; variable is always returned as numerical value
- [1] string; name of variable
- [2]
true
- string; name of variable, like
- every element either:
- Returns: none
- LuaWiki.isExisting( seek )
- Test page existence; like
#ifexist
seek
– string; full page name- Returns: boolean
- LuaWiki.setFrame( frame )
- Initialize frame for this utility by current template environment
frame
–frame
object- Returns: none
- LuaWiki.transclude( s, args )
- Save transclusion of a page, or error message
s
– string; full page name (if namespace not providedTemplate:
will be used)args
– table, optional; arguments- Returns: string; transclusion or error message if page missing
init
The initialization is important: On start the frame
object of current template environment needs to be set by LuaWiki.setFrame( frame )
– this won’t be checked any more.
Usage
[redakti fonton]General library; no limitations.
Dependencies
[redakti fonton]None.
Origin
[redakti fonton]- de:Vorlage:LuaWiki - 2013-05-04