Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
TemplatePar
– Module with support for template programming, focussing on parameters of template transclusion.
The analysis is operating on the template transclusion parameters. Parameters of #invoke
are described below; they are controlling the analysis.
class=error
.=
(equal sign).=
(equal sign).true
: ignore case0
.0
.1=
parameter name=
condition*
condition.class=error
. Fatal errors will be visible at following levels: Unknown parameter name – missing parameter – invalid parameter value.class=error
.true
: ignore caseThe 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):
Value | Result | current |
---|---|---|
nothingfalse
|
local version ID | »2023-03-20« |
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.
|
|
wikidata
|
version ID of global upstream
|
»2023-03-20« |
item
|
ID of the Wikidata item
| |
~
|
Corresponding version ID locally and registered at Wikidata
|
»« |
@
|
Is the current (module) page linked correctly with Wikidata item?
|
»Q15393417« |
The return value is in template programming empty or under Lua false , otherwis a non-empty string as described.
|
All functions described above which detect an error condition (check, valid as well as downcase, verify) maintain also the following parameters:
cat
as well.category:
prefix)@@@
is found in title and template
is provided, that will be replaced by template
.cat
triggering, otherwise causing the maintenance category to appear in all namespaces.class="error"
markup:
format
not provided.|format=*|
cat=
should be declared):
|format=|
|format=0|
|format=-|
|format=<start>Constant text</end>|
@@@
as placeholder for the unformatted default message text, any syntax.|format=<start>Constant text; @@@</end>|
|format=0|
has been requested:
|preview=1|
|preview=<start>Constant text</end>|
|preview=<start>Constant text; @@@</end>|
Use case on commons:Template:Information example:
((#invoke:TemplatePar
|check
|all= description= source= author=
|opt= date= permission= other_versions= other_fields=
|template=Information))
=
equal sign, those are used for separation of names. Whitespace before and after names will be ignored; as well as additional equal signs.all=
nor in opt=
will trigger an error message.all=
and opt=
.format=
since it has been caused by template programmer and not page author.all=
nor opt=
.all=
list is missing.all=
list is given with equal sign but no visible value, or an unnamed parameter is empty, leaving a gap between two pipe symbols.There are two methods for the optional condition 2:
/
to distinguish from keyword and detect closing and trailing whitespace on values of unnamed template parameters.|
as well as ((
and ))
are not possible in template programming. They are to be replaced:
|
→ %!
((
→ %((
))
→ %))
Key | Meaning | Implementation |
---|---|---|
ASCII
|
ASCII character (codes 32–126), within one line only, or empty | ^[ -~]*$
|
ASCII+
|
as before; not empty | ^[ -~]+$
|
ASCII+1
|
in one word; else as before und not empty | ^[!-~]+$
|
n
|
ASCII digits 0–9 only, and leading sign ASCII minus, or empty | ^[%-]?[0-9]*$ exclude single minus |
n>0
|
ASCII digits 0–9 only, no sign, not empty and and least one digit non-zero | ^[0-9]*[1-9][0-9]*$
|
N+
|
Like n ; but leading zero not permitted and not empty
|
^[%-]?[1-9][0-9]*$
|
N>0
|
Like n>0
|
^[1-9][0-9]*$ ; but leading zero not permitted
|
x
|
Hexdec number; ASCII digits 0–9 letters a–f A–F, or empty | ^[0-9A-Fa-f]*$
|
x+
|
as before; but not empty. | ^[0-9A-Fa-f]+$
|
X
|
Hexdec number; ASCII digits 0–9 letters A–F, or empty | ^[0-9A-F]*$
|
X+
|
as before; but not empty. | ^[0-9A-F]+$
|
0,0
|
Any number; also less than zero; might contain comma; or empty | ^[%-]?[0-9]*,?[0-9]*$ exclude single minus or comma |
0,0+
|
Any number; contains one comma; also less than zero | ^[%-]?[0-9]+,[0-9]+$
|
0,0+?
|
Any number; also less than zero; might contain comma and digits after comma; not empty | ^[%-]?[0-9]+,?[0-9]*$
|
0.0
|
Any number; also less than zero; might contain period; or empty | ^[%-]?[0-9]*[%.]?[0-9]*$ exclude single minus or comma |
0.0+
|
Number with period and significant figures; also less than zero | ^[%-]?[0-9]+%.[0-9]+$
|
0.0+?
|
Any number; also less than zero; might contain period and significant figures; not empty | ^[%-]?[0-9]+[%.]?[0-9]*$
|
.0+
|
Any number; also less than zero; might contain period and significant figures, but not necessarily digit before period; not empty | ^[%-]?[0-9]*[%.]?[0-9]+$
|
aa
|
At least two letters (not necessarily aside: N.N.) or a CJK | %a.*%a or CJK |
ID
|
Identifier with restrictions common to many languages: ASCII, beginning with letter; later digits and underscore; or empty. Subsequent ASCII words might be regarded as such identifiers, too; e.g. URL component. |
^[A-Za-z]?[A-Za-z_0-9]*$
|
ID+
|
as before; but not empty. | ^[A-Za-z][A-Za-z_0-9]*$
|
ABC
|
Word of ASCII capital letters; or empty. | ^[A-Z]*$
|
ABC+
|
as before; but not empty. | ^[A-Z]+$
|
Abc
|
Word of ASCII letters, first letter capitalized only; or empty. | ^[A-Z]*[a-z]*$
|
Abc+
|
as before; but not empty. | ^[A-Z][a-z]+$
|
abc
|
Word of ASCII lowercase letters; or empty. | ^[a-z]*$
|
abc+
|
as before; but not empty. | ^[a-z]+$
|
aBc+
|
Word of ASCII letters with lower camel casing; not empty. | ^[a-z]+[A-Z][A-Za-z]*$
|
base64
|
Base64; or empty. | ^[A-Za-z0-9%+/]*$
|
base64+
|
as before; but not empty. | ^[A-Za-z0-9%+/]+$
|
pagename
|
Permitted page name; not empty. | not #<>[]|{} or 12710 or 1–3110
|
|
Permitted title or name of a media file at
With | |
|
Condition: arithmetic comparison or (also) numeric inequality | |
url url+
|
empty or exactly one Internet URL (mandatory) |
|
ref
|
containing <ref> – Citation needed
|
|
|
empty or language code empty or space separated list of language codes |
|
In Planung | ||
date
|
Irgendein bekanntes Format für Datum und auch Zeit. | |
*
|
empty or arbitrary | |
+ nothing |
not empty | %S
|
A test page illustrates practical use.