Wikipedia:Lua/Modul/Vorlage:Handle/en

Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch English Modul: Dokumentation

Vorlage:Handle – Module to generate titled external links to web ressources by solver, transcluded by templates.

Template:Handle might be an abstract concept with two instances to be supported:

Functions for templates

f
Format.
Parameters from template transclusion:
1
Identifier
  • Might be escaped for URL or HTML, but after slash / only.
Alternatively:
Result of a previous evaluation; with URL or error message or as wikilink; even nothing.
problem
1 – show a remark about temporary unavailability
NoCat
1 – suppress general error category defined by errCat this time.
demo
1 – suppress any hiding of error messages this time; e.g. for documentation and examples
Parameters with #invoke for project specific adaption; all but scheme optional:
scheme
Code of coverage, mandatory:
  • doi
  • hdl
errCat
title of an error category for invalid DOI parameter etc.
errClasses
classes for selection of error messages; e.g. error
errHide
1 – hide error messages by default
errNS
space separated list of namespace numbers where to use errCat
default: all pages, all namespaces, if errCat defined
parProblem
name of „problem“ parameter – default: problem
showArticle
page name for doi: schema link – default: Digital Object Identifier
empty value: do not link schema
Returns: external link, or error message, maybe as class="error".
failsafe
Version identification

The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to

The Failsafe interface is present both at template level and for direct Lua access.

The functions in detail are (not all supported yet completely by every library):

Parameter
Value Result current
nothing
false
local version ID »2026-01-29«
Minimal version version ID required at least
date in ISO format

It will be compared whether the current local implementation matches this version or later.

  • empty, if minimal version not achieved
  • 2001-01-01 → »2026-01-29«
  • 2099-01-01 → »«
wikidata version ID of global upstream
  • version ID at Wikidata
  • local, if not found there
»2026-01-29«
item ID of the Wikidata item
  • empty if not defined
Q19644424
~ Corresponding version ID locally and registered at Wikidata
  • empty, if up to date
  • version ID at Wikidata, if not equal
»«
@ Is the current (module) page linked correctly with Wikidata item?
  • empty, if linked to the item which is supposed
  • Iitem ID, if not
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described.

Functions for Lua modules (API)

The functions described above can be used by other modules:

local lucky, Handle = pcall( require, "Module:Vorlage:Handle" )
if type( Handle ) == "table" then
    Handle = Handle()
else
    -- failure; Handle is the error message
    return "<span class=\"error\">" .. Handle .. "</span>"
end

Subsequently there are available:

Handle.main(argsF, argsT)
Interface to unit tests.
Same parameter tables as f.
  1. argsF
    table; #invoke parameter list
    • errNS entry may be either string or table of numbers
  2. argsT
    table; template parameter list
Return: string, with external link, or error message.
Handle.failsafe( atleast )
  • atleast
    optional
    nil or required version or wikidata or ~
Return: string or boolean

Dependencies