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

Bearbeiten
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 ID: 2019-07-14
optional parameter 1 – required version, or keyword wikidata or keyword ~
Returns:
  • empty, if minimal version condition not matched
  • local version otherwise, or registered version on Wikidata (2019-07-14) when keyword wikidata
  • empty, if keyword ~ and a registered version on Wikidata is the same as local; otherwise local version ID ()

Nowhere than by:

Functions for Lua modules (API)

Bearbeiten

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.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

Bearbeiten