Module:CSSUtil
This module is not used by any page. It was written for Module:Factory slot and Module:UI, to apply inline styles by class while this wiki had no TemplateStyles. Those modules now use Template:Crafting/styles.css instead. It is kept for reference.
hasClass(classAttr, className) returns true when the space-separated class list classAttr contains className. classAttr may be nil.
-- Utility for dealing with inline styles by checking
-- for CSS classes in a `class` argument.
--
-- Mainly exists to support inline style workarounds
-- until this Wiki gets [[mw:Extension:TemplateStyles|TemplateStyles]]
require("Module:No globals");
local checkType = require("libraryUtil").checkType;
local p = {};
--- Returns whether the space separated
--- `classAttr` contains the `className`
---
--- @param classAttr string|nil the class attribute
--- @param className string the class name to look for
--- @return boolean
function p.hasClass(classAttr, className)
checkType('"Module:CSSUtil".hasClass', 1, classAttr, "string", true);
checkType('"Module:CSSUtil".hasClass', 2, className, "string");
-- assert(not className:find("%s"), 'Class name must not contain whitespace, got: "' .. className .. '"');
if (not classAttr) then
return false;
end
for cls in mw.text.gsplit(classAttr, "%s+") do
if (cls == className) then
return true;
end
end
return false;
end
return p;