OneShot Wiki
m (Test)
m (Uh)
Line 18: Line 18:
 
local cols = frame.args[1]
 
local cols = frame.args[1]
 
local template = frame.args[2]
 
local template = frame.args[2]
table.remove(args, 1)
+
table.remove(args, '1')
 
--if frame.args[3] then
 
--if frame.args[3] then
 
-- local del = tonumber(frame.args[3])
 
-- local del = tonumber(frame.args[3])

Revision as of 21:16, 20 January 2017

Documentation for this module may be created at Module:Loops/doc

local p = {};

function template_args()
    return mw.getCurrentFrame():getParent().args
end

function p.translation(frame)
    local args = template_args()
    local ret = ''
    for i, v in ipairs(args) do
        ret = ret .. '{{Translation/element|' .. v .. '}} • '
    end
    return frame:preprocess(ret .. '{{Translation/element}}')
end

function p.loop(frame)
    local args = template_args()
    local cols = frame.args[1]
    local template = frame.args[2]
    table.remove(args, '1')
    --if frame.args[3] then
    --    local del = tonumber(frame.args[3])
    --    while(del > 0) do
    --        table.remove(args, 1)
    --        del = del - 1
    --    end
    --end
    return args[1]
    --local data = {}
    --local ret = ''
    --for i, v in ipairs(args) do
    --    local index = math.ceil(i / cols)
    --    if not(data[index]) then
    --        data[index] = {}
    --    end
    --    data[index][((i - 1) % cols) + 1] = v
    --end
    --for i, v in ipairs(data) do
    --    ret = ret .. '{{' .. template .. '/element|'
    --    for i2, v2 in ipairs(v) do
    --        ret = ret .. v2 .. '|'
    --    end
    --    ret = ret .. '}}'
    --end
    --return frame:preprocess(ret)
end

return p