Модуль:Repeat

З пляцоўкі Вікікрыніцы

Дакументацыю да гэтага модуля можна стварыць у Модуль:Repeat/Дакументацыя

--
-- Copied from uk.wikisource
--
local p = {}

-- 
function p.out(frame)
	local symbol = frame.args[1]
	local n_skip = tonumber(frame.args[2])
	local nmax = tonumber(frame.args[3])
	local str, n, skip
	
	skip = ''
	str = symbol
	if nmax == nil then
		nmax = 100
	end

	n = 1
	while n <= n_skip do
		skip = skip .. '&nbsp;'
		n = n + 1
	end
	
	n = 1
	while n <= nmax do
		str = str .. skip .. symbol
		n = n + 1
	end

	return frame:preprocess(str)
end 	
--
-- 
function p.symbol(frame)
	local nmax = tonumber(frame.args[1])
	local symbol = frame.args[2]
	local str, n
	
	if nmax == nil then
		nmax = 0
	end
	if symbol == nil then
		symbol = '&nbsp;'
	end
	str = ''
	
	n = 1
	while n <= nmax do
		str = str .. symbol
		n = n + 1
	end

	return frame:preprocess(str)
end 	
--
return p