Die Dokumentation für dieses Modul kann unter Modul:Vorlage:Auflistung/doc erstellt werden
local HorizontalList = { suite = "HorizontalList",
serial = "2020-10-02",
item = 0 }
-- Horizontal list of items by HTML/CSS list
HorizontalList.classes = { }
HorizontalList.styles = "Template:Subpage/styles.css"
table.insert( HorizontalList.classes, "breadcrumb-nav-container" )
table.insert( HorizontalList.classes, "breadcrumb-nav-middot" )
HorizontalList.f = function ( all, altogether, frame )
-- Generate horizontal list from wikitext
-- Parameter:
-- all -- string, with wikitext
-- each line starting with one of * or #
-- altogether -- true, if nowrap around each regular item
-- frame -- object, if available
-- Returns string
local r
if type( all ) == "string" then
local story = mw.text.trim( all )
local s = story:sub( 1, 1 )
if s == "#" or s == "*" then
local list = ( s == "#" )
local items, got
if list then
s = "\n%s*#%s*"
else
s = "\n%s*%*%s*"
end
items = mw.text.split( story:sub( 2 ), s )
for i = 1, #items do
s = mw.text.trim( items[ i ] )
if s ~= "" then
got = got or { }
table.insert( got, s )
end
end -- for i
if got then
r = HorizontalList.fiat( got, list, altogether, frame )
else
r = ""
end
else
r = story
end
elseif all then
r = tostring( all )
else
r = ""
end
return r
end -- HorizontalList.f()
HorizontalList.fiat = function ( all, advance, altogether, frame )
-- Generate horizontal list from wikitext
-- Parameter:
-- all -- table, with sequence of items
-- each item is a string or a mw.html object
-- advance -- true, if ordered list requested
-- altogether -- true, if nowrap around each item
-- frame -- object, if available
-- Returns string
local r
if type( all ) == "table" then
local e
if #all > 1 then
local ou, s
if advance then
s = "ol"
else
s = "ul"
end
ou = mw.html.create( s )
if type( HorizontalList.classes ) == "table" then
for i = 1, #HorizontalList.classes do
ou:addClass( HorizontalList.classes[ i ] )
end -- for i
end
for i = 1, #all do
e = mw.html.create( "li" )
s = all[ i ]
if type( s ) == "table" then
e:node( s )
else
e:wikitext( tostring( s ) )
end
if altogether then
e:css( "white-space", "nowrap" )
end
ou:newline()
:node( e )
end -- for i
if type( frame ) ~= "table" then
frame = mw.getCurrentFrame()
end
r = frame:extensionTag( "templatestyles",
nil,
{ src = HorizontalList.styles } )
r = r .. tostring( ou )
else
r = all[ 1 ]
if altogether then
if type( r ) == "table" then
r:css( "white-space", "nowrap" )
else
r = mw.html.create( "span" )
:css( "white-space", "nowrap" )
:wikitext( tostring( r ) )
end
end
r = tostring( r )
end
end
return r or ""
end -- HorizontalList.fiat()
-- Export
local p = { }
p.f = function ( frame )
-- Template call
return HorizontalList.f( frame.args[ 1 ],
frame.args.nowrap == "1",
frame )
end -- p.f
p.HorizontalList = function ()
-- Module interface
return HorizontalList
end
p.Auflistung = function ()
-- Module interface
return HorizontalList
end
return p