ФЭНДОМ


-- <nowiki>
local p = {}
 
local function paired(args)
    local function iter(a, i)
        local v1 = a[i+1]
        local v2 = a[i+2]
        i = i + 2
 
        if v1 and v2 then
            return i, v1, v2 
        end
    end
    return iter, args, 0
end
 
function p.main(frame)
    frame = frame:getParent()
 
    if not frame.args[1] then
        return ''
    end
 
    local slider = mw.html.create('div')
        :attr('class', 'carousel-slider')
            :tag('div')
            :attr('class', 'overflow')
                :tag('ul')
 
    local size = 0
    for _, image, link in paired(frame.args) do
        image = mw.text.trim(image)
        link = mw.text.trim(link)
 
        slider
            :tag('li')
                :tag('div')
                :attr('class', 'block')
                :wikitext('[[Файл:'..image..'|x280px|link='..link..']]')
                :done()
                :tag('div')
                :attr('class', 'details')
                :wikitext('[['..link..']]')
                :done()
            :done()
        size = size + 1
    end
 
    if size <= 4 then
        slider:allDone():attr('class', 'carousel-slider not-carousel')
    end
 
    return tostring(slider:allDone())
end
 
return p