Module:Template style
Jump to navigation
Jump to search
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