Modulo:Cassetto
Aspetto
Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:Cassetto/man (modifica · cronologia)
Sandbox: Modulo:Cassetto/sandbox (modifica · cronologia) · Test: Modulo:Cassetto/test (modifica · cronologia · Esegui)
Vedi anche
--[[
Source script: https://it.wikivoyage.org/wiki/Modulo:Cassetto
Maintainer: Andyrom75
]]
local function _templateStyle( frame, src )
return frame:extensionTag( 'templatestyles', '', { src = src } )
end
local function _isDefined(s)
return s ~= '' and s
end
local p={}
function p.Cassetto( frame )
local args={}
if frame == mw.getCurrentFrame() then
args = frame:getParent().args
else
args = frame
end
local float
if _isDefined( args.allineamento ) then
if args.allineamento == 'sinistra' then
float = 'float:left'
elseif args.allineamento == 'destra' then
float = 'float:right'
end
end
local html = mw.html.create( 'div' )
:addClass( 'cassetto mw-collapsible' )
:addClass( (not _isDefined( args.aperto )) and 'mw-collapsed' )
:cssText( _isDefined( args.larghezza ) and ('width:' .. args.larghezza) )
:cssText( _isDefined( args.coloresfondo ) and ('background:' .. args.coloresfondo .. ';color:inherit') )
:cssText( _isDefined( args.affiancabile ) and 'clear:none' )
:cssText( _isDefined( float ) and float )
local nodo = mw.html.create()
local livello = 0
if tonumber(args.livello ) then
livello = math.floor( args.livello )
if (livello > 0) and (livello < 7) then
nodo:node('<H'..livello..'>')
end
end
nodo:wikitext( args[1] or args.titolo or '' )
if (livello > 0) and (livello < 7) then
nodo:node('</H'..livello..'>')
end
html:cssText( _isDefined( args.senzabordo ) and 'border:0' or 'border:1px solid #AAAAAA' )
:tag('div')
:addClass( 'cassetto-titolo' )
:cssText( _isDefined( args.colore ) and ('background:' .. args.colore .. ';color:inherit') )
:node( nodo )
:done()
:tag('div')
:addClass( 'mw-collapsible-content' )
:cssText( _isDefined( args.coloresfondo ) and ('background-color:' .. args.coloresfondo .. ';color:inherit') )
:wikitext( args[2] or args.testo or args.contenuto or '' )
return _templateStyle( frame, 'Cassetto/styles.css' ) .. tostring(html)
end
return p