Wikipedia:Lua/Modul/TemplateData/en

Dies ist eine alte Version dieser Seite, zuletzt bearbeitet am 25. Juli 2017 um 09:50 Uhr durch PerfektesChaos (Diskussion | Beiträge) (Setup). Sie kann sich erheblich von der aktuellen Version unterscheiden.
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Vorlagenprogrammierung Diskussionen Lua Test Unterseiten
Modul Deutsch English

Modul: Dokumentation

TemplateData – Module with auxilary functions for template documentation, especially by TemplateData.

Core functionality is improved presentation on documentation pages.

Functions for templates

Single functions

f
Improve TemplateData-presentation; used in Template:TemplateData
Parameters of template transclusion environment (all optional):
1
JSON string or <templatedata> object
JSON
JSON string
(precedes 1)
Transition from <templatedata> objects with pipe symbols needs special attention: Pipes are to be represented as {{!}}, on double curly brackets one should be encoded by HTML entity.
TOC
1 – Insert table of contents after general purpose descriptions; but before parameter list, if present
Example
lazy
1 – Presentation only, do not generate an effective data block
For general method descriptions.
debug
1 – developer mode
Parameters of #invoke for particular project adaption (all optional):
cat
Title of a maintenance category on invalid parameter value etc.
debug
Development mode, if provided and not equal 0
docpageCreate
Pattern for creation of subpage names; %s/Doku
docpageDetect
Pattern for recognition of subpage names; /Doku$
msgDescMiss
Localisation: complaint text on missing description
Returns: HTML code; and/or error message, probably with class="error"
failsafe
Version identification: 2025-02-07
Optional additional parameter 1 – requested minimal version identification
Returns: empty, if minimal version condition not matched

Examples (test page)

A test page illustrates practical use.

Functions for Lua modules (API)

Some functions described above can be used by other modules:

local lucky, TemplateData = pcall( require, "Modul:TemplateData" )
if type( TemplateData ) == "table" then
    TemplateData = TemplateData.TemplateData()
else
    -- failure; TemplateData is the error message
    return "<span class='error'>" .. TemplateData .. "</span>"
end
TemplateData.failsafe(atleast)
  1. atleast
    optional
    nil or minimal version request
Returns: string or false
TemplateData.getPlainJSON(adapt)
Reduce enhanced JSON information to MediaWiki JSON
  1. adapt
    string, with JSON (enhanced)
Returns: string, with JSON (MediaWiki )
TemplateData.test(adapt, arglist)
Simulation of template functionality
  1. adapt
    table, #invoke parameters
  2. arglist
    table, template parameters
Returns: string

Usage

Currently focussing on one template only:

Dependencies