Module:Color list
Documentation for this module may be created at Module:Color list/doc
require "table"
local color = require "Module:Css color"
local p = {}
-- Apply a template to each item in the list
function p.exec(frame)
local args = frame:getParent().args[1]
if args == "" then return "" end
local out = {}
for x in mw.text.gsplit(args, args.sep or "%s*,%s*") do
local pair = mw.text.split(x, ":")
local head = "[[" .. pair[1] .. "]]"
if #pair == 1 then
local c = color.get{args={pair[1]}}
if c ~= "" then
pair[2] = c
end
end
if #pair > 1 then
out[#out + 1] = frame:expandTemplate{title="pair", args={
head, frame:expandTemplate{title="color box", args={pair[2]}}
}}
else
out[#out + 1] = head
end
mw.smw.set{"color", pair[1]}
end
return mw.text.listToText(out, ", ", ", ")
end
return p