Module:String/Templates

local loadLib = require('Module:LoadLib')

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

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

return p