Modul:TemplateData: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
2017-04-10
wp>PerfektesChaos (2017-04-09) |
wp>PerfektesChaos (2017-04-10) |
||
Zeile 1: | Zeile 1: | ||
local TemplateData = { serial = "2017-04- | local TemplateData = { serial = "2017-04-10", | ||
suite = "TemplateData" } | suite = "TemplateData" } | ||
--[=[ | --[=[ | ||
Zeile 26: | Zeile 26: | ||
less = false, -- main description missing | less = false, -- main description missing | ||
lasting = false, -- old syntax encountered | lasting = false, -- old syntax encountered | ||
lazy = false, -- doc mode; do not generate effective <templatedata> | |||
leading = false, -- show TOC | |||
-- low = false, -- 1= mode | -- low = false, -- 1= mode | ||
order = false, -- parameter sequence | order = false, -- parameter sequence | ||
Zeile 149: | Zeile 151: | ||
return r | return r | ||
end -- facet() | end -- facet() | ||
Zeile 424: | Zeile 382: | ||
end | end | ||
end -- fathers() | end -- fathers() | ||
local function feasible( about, asked ) | |||
-- Create description head | |||
-- Parameter: | |||
-- about -- table, supposed to contain description | |||
-- asked -- true, if mandatory description | |||
-- Returns <block>, with head, or nil | |||
local para = mw.html.create( "p" ) | |||
local plus, r | |||
if about and about.description then | |||
if type( about.description ) == "string" then | |||
para:wikitext( about.description ) | |||
else | |||
para:wikitext( about.description[ 1 ] ) | |||
plus = mw.html.create( "ul" ) | |||
:addClass( "templatedata-maintain" ) | |||
:css( "display", "none" ) | |||
for k, v in pairs( about.description[ 2 ] ) do | |||
plus:node( mw.html.create( "li" ) | |||
:node( mw.html.create( "code" ) | |||
:wikitext( k ) ) | |||
:node( "br" ) | |||
:wikitext( fair( v ) ) ) | |||
end -- for k, v | |||
end | |||
elseif Config.solo and asked then | |||
para:addClass( "error" ) | |||
:wikitext( Config.solo ) | |||
Data.less = true | |||
else | |||
para = false | |||
end | |||
if para then | |||
if plus then | |||
r = mw.html.create( "div" ) | |||
:node( para ) | |||
:node( plus ) | |||
else | |||
r = para | |||
end | |||
end | |||
return r | |||
end -- feasible() | |||
Zeile 551: | Zeile 554: | ||
-- description etc. | -- description etc. | ||
s = | s = feasible( param ) | ||
if s then | if s then | ||
desc:node( s ) | desc:node( s ) | ||
Zeile 911: | Zeile 914: | ||
-- Returns <div> | -- Returns <div> | ||
local r = mw.html.create( "div" ) | local r = mw.html.create( "div" ) | ||
local s = | local s = feasible( Data.tree, true ) | ||
if s then | if s then | ||
r:node( s ) | r:node( s ) | ||
end | |||
if Data.leading then | |||
r:newline() | |||
:wikitext( "__TOC__" ) | |||
:newline() | |||
end | end | ||
s = features() | s = features() | ||
if s then | if s then | ||
if Data.leading then | |||
r:node( mw.html.create( "h2" ) | |||
:wikitext( factory( "doc-params" ) ) ) | |||
:newline() | |||
end | |||
r:node( s ) | r:node( s ) | ||
end | end | ||
Zeile 961: | Zeile 974: | ||
end | end | ||
Data.div:node( format() ) | Data.div:node( format() ) | ||
Data.slim = flush() | if not Data.lazy then | ||
Data.slim = flush() | |||
if TemplateData.frame then | |||
local div = mw.html.create( "div" ) | |||
local tdata = { [ 1 ] = "templatedata", | |||
[ 2 ] = Data.slim } | |||
Data.strip = TemplateData.frame:callParserFunction( "#tag", | |||
tdata ) | |||
div:wikitext( Data.strip ) | |||
if Config.loudly then | |||
Data.div:node( mw.html.create( "hr" ) ) | |||
else | |||
div:css( "display", "none" ) | |||
end | |||
Data.div:node( div ) | |||
end | end | ||
end | end | ||
end -- full() | end -- full() | ||
Zeile 996: | Zeile 1.011: | ||
Config.loudly = true | Config.loudly = true | ||
end | end | ||
Data.lazy = faculty( arglist.lazy ) and not Config.loudly | |||
Data.leading = faculty( arglist.TOC ) | |||
if arglist.JSON then | if arglist.JSON then | ||
source = arglist.JSON | source = arglist.JSON |