Modul:SimpleLinkList
Erscheinungsbild
Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
--[=[ SimpleLinkList 2022-02-10
simple link list generators for navigation in simmilar pages
Param for all methods: lemmas, comma separated
* culled: links to lemmas, hyphen separated, current page culled
* highlighted: links to lemmas, hyphen separated, current page highlighted
* stacked: links to lemmas, line break separated, current page culled
]=]
p = {}
p.culled = function(frame)
if frame.args[1] == nil then
return frame:preprocess('[[Modul:SimpleLinkList]]')
end
local Param = mw.text.split(frame.args[1], ',')
local result = ""
for _, v in ipairs(Param) do
if v ~= mw.title then
result = result .. ' - ' .. frame:preprocess('[[' ..
string.gsub(v, '^%s*(.-)%s*$', '%1') .. ']]')
end
end
return mw.ustring.sub(result, 4)
end
p.stacked = function(frame)
if frame.args[1] == nil then
return frame:preprocess('[[Modul:SimpleLinkList]]')
end
local Param = mw.text.split(frame.args[1], ',')
local result = ""
for _, v in ipairs(Param) do
if v ~= mw.title then
result = result .. '<br />' .. frame:preprocess('[[' ..
string.gsub(v, '^%s*(.-)%s*$', '%1') .. ']]')
end
end
return mw.ustring.sub(result, 7)
end
p.highlighted = function(frame)
if frame.args[1] == nil then
return frame:preprocess('[[Modul:SimpleLinkList]]')
end
local Param = mw.text.split(frame.args[1], ',')
local result = ""
for _, v in ipairs(Param) do
if v == mw.title then
result = result .. ' ' ..
'<span class="highlighted">' .. v .. '</span>'
else
result = result .. ' - ' .. frame:preprocess('[[' ..
string.gsub(v, '^%s*(.-)%s*$', '%1') .. ']]')
end
end
return mw.ustring.sub(result, 2)
end
return p