Wikipedia:Lua/Modul/LuaWiki/en
Wikipedia:Lua Modul LuaWiki en
| Vorlagen- programmierung |
Diskussionen | Lua | Unterseiten | ||||||
| Modul | Deutsch | English
|
Esperanto | Dolnoserbski | Hornjoserbsce | Modul: | WP:Lua | ||
LuaWiki – Module with functions for Lua programming in context of a Wiki project.
Functions for templates
No direct usage by templates.
Functions for Lua modules (API)
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:Parserfunktionen
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 )
- 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
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
General library; no limitations.
Dependencies
None.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.