FANDOM


-- <nowiki>
local p = {}
 
function p.exists(frame)
    local offset = frame.args[1] or 0
    local limit = frame.args[2] or 500
    local namespace = frame.args[3] or 'Template'
    local redirects = frame.args[4] or 'exclude'
    local dpl = frame:preprocess('{{#dpl:|titleregexp = .*/.*|namespace = ' .. namespace .. '|offset = ' .. offset .. '|count = ' .. limit .. '|redirects = ' .. redirects .. '|format = ,%PAGE%,{{!}},}}')
    local res = ''
    for k, v in ipairs(mw.text.split(dpl, '|')) do
        if v:len() > 0 then
            local template, _ = v:gsub('/[^/]*$', '')
            local dpl2 = mw.text.trim(frame:preprocess('{{#dpl:|title = ' .. template .. '}}'))
            if dpl2:len() > 0 then
                res = res .. '* [[' .. v .. ']] - [[' .. template .. ']]\n'
            end
        end
    end
    return res
end
 
return p
-- </nowiki>
Community content is available under CC-BY-SA unless otherwise noted.