模块:Seplist

来自Hyacinth
草awa留言 | 贡献2024年7月2日 (二) 06:55的版本 (Created page with "--Module to implement an unordered list with a generalised separator. Use TemplateStyles with an associated template to style the list. It will recognise "hr" as the horizontal rule. -- p = {} p.makelist = function(frame) local args = frame.args if not args[1] then args = frame:getParent().args if not args[1] then return end end local sep = (args.sep or "") if sep == "hr" then sep = "<hr>" end local out = {} for k, v in ipairs(args) do v = mw.text.tri...")
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转到导航 跳转到搜索

此模块的文档可以在模块:Seplist/doc创建

--[[
Module to implement an unordered list with a generalised separator.
Use TemplateStyles with an associated template to style the list.
It will recognise "hr" as the horizontal rule.
--]]

p = {}

p.makelist = function(frame)
	local args = frame.args
	if not args[1] then
		args = frame:getParent().args
		if not args[1] then return end
	end
	local sep = (args.sep or "")
	if sep == "hr" then sep = "<hr>" end
	local out = {}
	for k, v in ipairs(args) do
		v = mw.text.trim(v)
		table.insert(out, "<li>" .. v .. "</li>")
	end
	if #out > 0 then
		return '<ul class="seplist">' .. table.concat(out, sep) .. '</ul>'
	end
end

return p