Module:String/Templates

require('Module:LoadLib')(_G, {	string='Module:String',	{ 'Module:Constructor' }, }, { autoloads=false })

local mergeArgsSyntax = require('Module:Arguments').mergeArgsSyntax

local p = {}

--- -- Template:Repeat -- -- Repeats the given string a specified number of times --- function p.repeatF(frame) local args = getArgs(frame, {removeBlanks = false}) local s = args[1] or "" local num = args[2] or "1" local sep = args[3] if num:match('[^%d%-%+]+') then return string.error('number expected, got "%s"', tonumber(num)) elseif 0 >= tonumber(num) then return string.error('repeat delimiter must be greater than 0, got %s', num) end return p._repeat(s, num, sep) end - -- Template:Code -- -- Creates a piece of formatted code. - function p.code(frame) local args = getArgs(frame, { removeBlanks=false })

local tmp = args["inline"] or args["i"] local contentOnly = yesno(args["conly"] or args["contentonly"] or args["only"], false) if not Boolean(tmp) and tmp ~= nil then tmp = false end local inline = tmp ~= false and 1 or nil

return (args["lang"] or args["l"]) and mw.getCurrentFrame:extensionTag('source', args["code"] or args[1], {			inline=inline,			lang=args["lang"] or args["l"],			class=(args["class"] or args["cl"] or )..(contentOnly and " contents-only" or )		}) or string.wrapHtml(args["code"] or args["c"] or args[1] or '', ' ', {			class="code",		}) end

- -- Template: Style -- -- Makes making CSS easier. - function p.style(frame) local ret = {} for prop, value in pairs(getArgs(frame)) do		table.push(ret, prop, ": ", value, "; ") end return table.concat(ret, "") end

- -- Template: ClassList -- -- Creates an HTML Class List. - function p.classList(frame) local t = mergeArgsSyntax(getArgs(frame)) local ret = {} for i, v in ipairs(t) do		table.push(ret, v)	end return table.concat(ret, " ") end

return p