Module:Test Lua VisualData: Difference between revisions

From Visual Data Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Tag: Reverted
Line 2: Line 2:


function p.testlua(frame)
function p.testlua(frame)
     if mw.visualdata == nil then
     if mw.visualdata.query == nil then
         return "Error: visualdata module is not available."
         return "Error: visualdata module is not available."
     end
     end

Revision as of 08:10, 16 August 2024

Documentation for this module may be created at Module:Test Lua VisualData/doc

local p = {}

function p.testlua(frame)
    if mw.visualdata.query == nil then
        return "Error: visualdata module is not available."
    end

    local schema = "Project key data"
    local query = "[[category::Projects]]"
    local printouts = {"objective", "image", "description"}

    local results = mw.visualdata.query(schema, query, printouts)

    local output = ""
    for _, result in ipairs(results) do
        output = output .. "Objective: " .. (result.objective or "N/A") .. "<br>"
        output = output .. "Image: " .. (result.image or "N/A") .. "<br>"
        output = output .. "Description: " .. (result.description or "N/A") .. "<br><br>"
    end

    return output
end

return p