Modulo:Vedi anche/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
aggiornato stile documentazione a quello usato in Mediawiki per Lua, +string.format, fix minori |
m Bot: rimuovo no globals obsoleto |
||
(10 versioni intermedie di un altro utente non mostrate) | |||
Riga 1:
--[[
* Modulo che implementa
]]
require('
-- Parsifica un argomento del template (rappresenta il titolo di una pagina) e ne restituisce il wikilink.
Riga 12:
local dest, count
--
if arg:match('^%s*:%s*[Cc][Aa][Tt]') then
return '<span class="error">(usare il [[Template:Vedi categoria]])</span>'
Riga 24:
dest = arg
arg, count = arg:gsub('#', ' § ')
dest = count == 1 and (dest .. '|') or ''
return string.format("'''[[
end
Line 31 ⟶ 32:
--
-- @param {string} wikitext
-- @return {string}
local function buildHTML(wikitext
local tableNode = mw.html.create('table')
tableNode
:addClass(
:tag('tr')
:tag('td')
:wikitext('[[File:Magnifying glass icon mgx2.svg|20px|class=noviewer|link=]]')
:done()
:tag('td')
:wikitext(string.format("''Lo stesso argomento in dettaglio: %s''.", wikitext))
:done()
Line 63 ⟶ 53:
local p = {}
end▼
-- Funzione per il template {{Vedi anche}}.
function p.main(frame)
local lastArg, conjunction
local styles = 'Modulo:Vedi anche/sandbox/styles.css'
local args = {}
for _, val in ipairs(frame:getParent().args) do
if mw.text.trim(val) ~= '' then
table.insert(args, parseArg(val))
lastArg = val
▲ end
end
if #args > 1 and lastArg then
Line 85 ⟶ 71:
end
return frame:extensionTag{
return buildHTML(mw.text.listToText(args, ', ', conjunction), true)▼
name = 'templatestyles',
args = {src = styles}
end
|