Module:Aside: Difference between revisions

From Terra Nostra
Created page with "local p = {} function p.show(frame) local args = frame:getParent().args local pieces = {} for _, a_full in ipairs(args) do a_delim = mw.ustring.find(":") if a_delim then a_pre = mw.ustring.sub(a_full, 1, a_delim - 1) a_post = mw.ustring.sub(a_full, a_delim + 1) table.insert(pieces, "<small>" .. a_pre .. ":</small> " .. a_post) else table.insert(pieces, a_full) end end return "(" .. table.concat(pieces, ", ") .. ")" end return p"
 
No edit summary
 
Line 5: Line 5:
local pieces = {}
local pieces = {}
for _, a_full in ipairs(args) do
for _, a_full in ipairs(args) do
a_delim = mw.ustring.find(":")
a_delim = mw.ustring.find(a_full, ":")
if a_delim then
if a_delim then
a_pre = mw.ustring.sub(a_full, 1, a_delim - 1)
a_pre = mw.ustring.sub(a_full, 1, a_delim - 1)

Latest revision as of 01:35, 9 September 2024

Documentation for this module may be created at Module:Aside/doc

local p = {}

function p.show(frame)
	local args = frame:getParent().args
	local pieces = {}
	for _, a_full in ipairs(args) do
		a_delim = mw.ustring.find(a_full, ":")
		if a_delim then
			a_pre = mw.ustring.sub(a_full, 1, a_delim - 1)
			a_post = mw.ustring.sub(a_full, a_delim + 1)
			table.insert(pieces, "<small>" .. a_pre .. ":</small> " .. a_post)
		else
			table.insert(pieces, a_full)
		end
	end
	return "(" .. table.concat(pieces, ", ") .. ")"
end

return p