Module:Indicator datasets table

From Visual Data Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:Indicator datasets table/doc

local p = {}

function p.getDatasets(frame)
    local articleids = frame.args.articleids
    if not articleids then
        return "Error: articleids not provided"
    end
    
    local ids = mw.text.split(articleids, ",")
    local pagecontent = {}
    
    for _, id in ipairs(ids) do
        local titleobject = mw.title.new(tonumber(id))
        local existspage = titleobject.exists
        
        if existspage then
            local content = titleobject:getContent()
            -- Speichere den Inhalt der Seite
            table.insert(pagecontent, content)
        else
            table.insert(pagecontent, "Error: Page not found for ID " .. id)
        end
    end
    
    -- Erstelle für jeden Inhalt ein <div>-Element
    local result = {}
    for _, content in ipairs(pagecontent) do
        table.insert(result, '<div>' .. content .. '</div>')
    end
    
    -- Gib alle <div>-Elemente als zusammengefügten String zurück
    return table.concat(result, "\n")
end

return p