Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

This implements Template:Template style. The provided CSS text is hashed, and the hash value used to construct a unique variable name. That variable is then used, via Extension:Variables, to check/store whether the given CSS was already added to the page or not.


local p = {}

function p.main(frame)
	local css = frame:getParent().args[1]
	local hash = mw.hash.hashValue("xxh3", css)
	local v = "TemplateStyleApplied-" .. hash
	local check = frame:callParserFunction("#var", v, "0")
	if check == "0" then
		frame:callParserFunction("#css", css)
		frame:callParserFunction("#vardefine", v, "1")
	end
end

return p