Module:Color pair

From para.wiki
Revision as of 21:01, 6 February 2019 by Anonymous
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

local color = require "Module:Css color"

local p = {}

function p.exec(frame)
	local pair = mw.text.split(frame:getParent().args[1], ":")
	
	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
		return frame:expandTemplate{title="pair", args = {
			head, frame:expandTemplate{title="color box", args={pair[2]}}
		}}
	else
		return head
	end
end

return p