Modulo:Sup
Vai alla navigazione
Vai alla ricerca
Manuale del modulo
Questo modulo crea link ai giochi, mostrandoli in apice con le loro abbreviazioni colorate. L'elenco delle sigle utilizzabili è disponibile in questa pagina.
Esempi
Codice | Risultato |
---|---|
{{#invoke: Sup | UL }} |
Ul |
{{#invoke: Sup | NBN2B2 }} |
NBN2B2 |
Se si riceve un errore script significa che la sigla in questione non è disponibile. Esistono due metodi per rimediare:
Codice | Risultato |
---|---|
{{#invoke: Sup | OACPtHGSS }} |
[Errore script] |
{{#invoke: Sup | OAC | Pt | HGSS }} |
OACPtHGSS |
{{#invoke: Sup | _abbr | OAC Pt HGSS }} |
OACPtHGSS |
Il secondo è particolarmente indicato per i casi in cui la prima abbreviazione non è costante, per esempio i parametri dei template.
--[[
This module creates link to games, displaying them in superscripts with
colored abbreviations.
Examples:
{{#invoke: Sup | UL }}
{{#invoke: Sup | RZS | RFVF}}
{{#invoke: Sup | HGSS | XY | ROZA }}
HINT: If you get an Errore Script, try to split an abbreviation into smaller
parts. For example:
{{#invoke: Sup | OACPtHGSS }} --> {{#invoke: Sup | OAC | Pt | HGSS }}
However, this doesn't work if the first abbreviation is not constant, for
example if it's a parameter in a template. In that case, you can use the
_abbr function to pass all the abbreviations as parameters:
{{#invoke: Sup | _abbr | {{{1}}} }}
--]]
local lib = require('Modulo:Wikilib/sigle')
-- Creates the links for a single abbreviation, as a single string
local makeLinks = function(data)
return table.concat(lib.coloredAbbrLinks(data, lib.bolden))
end
-- Wraps a list of links content in sup tags
local makeSup = function(links)
table.insert(links, 1, '<sup>')
table.insert(links, '</sup>')
return table.concat(links)
end
-- Dynamically generated Wikicode interface
local sup = lib.mapAbbrs(function(_, abbr)
--[[
Wikicode arguments are first processed one-by-one by makeLinks,
resulting in a table having a string for every argument, containing
all the links. These strings are then concatenated and wrapped in sup
tags by makeSup.
--]]
return lib.onMergedAbbrs(abbr, makeLinks, makeSup)
end)
-- Adding _abbr proxy function
lib.proxy(sup)
return sup