Wikipedija:Lua/Module/LuaWiki/en
Napohlad
| Programowanje předłohi | Diskusije | Lua | Testy | Podstrony | ||||
|---|---|---|---|---|---|---|---|---|
| Modul | Hornjoserbsce | English | Deutsch | Modul: | Dokumentacija | |||
LuaWiki – Module with functions for Lua programming in context of a Wiki project.
Functions for templates
[žórłowy tekst wobdźěłać]No direct usage by templates.
Functions for Lua modules (API)
[žórłowy tekst wobdźěłać]The Lua Scribunto Debug Console is a safe, interactive tool for learning Modul:LuaWiki.
- Click
Edit sourceon the Modul:LuaWiki page. - Do not modify the Lua code in the editor and do not click
Publish changes. - Scroll to the bottom of the page to the
Debug consolesection. - Paste the following into the gray input box (above the
Clearbutton).
local LuaWiki = require("Modul:LuaWiki") -- load the LuaWiki module print(type(LuaWiki)) -- A Lua module must return a table print(LuaWiki.isExisting("Modul:LuaWiki")) -- Does Modul:LuaWiki exist? print(LuaWiki.getVariable("PAGENAME", false)) -- Get the title of the current page
- Press ↵ Enter once to execute all Lua commands.
- The result will appear below the Lua
printcommand line:
table true LuaWiki
- Press
Up arrow(↑) to cycle through previous Lua commands. - Optionally, click
Clearto clear only theDebug Console; the Lua editor above will remain unmodified.
Thereafter the functions can be accessed.
- 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 de:Hilfe: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
#ifexistseek– string; full page name- Returns: boolean
LuaWiki.setFrame(frame)- Deprecated: Initialize frame for this utility by current template environment
frame–frameobject- 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
- LuaWiki.error(msg)
- HTML generator of error message
msg– string; error message- Returns: string; HTML error message
In Debug console of Modul:LuaWiki:
local LuaWiki = require("Modul:LuaWiki") -- load the LuaWiki module print(LuaWiki.getArg("argUnknown")) -- Get unknown arg print(LuaWiki.error("LuaWiki.setFrame(frame) is deprecated")) -- setFrame doesn't exist
{{{<argUnknown>}}} Lua-zmylk: LuaWiki.setFrame(frame) is deprecated. Wróćoslědowanje: [C]: in function "error" Modul:LuaWiki:32: in function "error" console input:13: ? [C]: ?
- Click
Cancelbeneath the Lua editor. - The
Module:LuaWiki remains unmodified.
Usage
[žórłowy tekst wobdźěłać]General library; no limitations.
Dependencies
[žórłowy tekst wobdźěłać]None.
Origin
[žórłowy tekst wobdźěłać]- de:Vorlage:LuaWiki - 2013-05-04