Module:CommonData/View

-- CommonData View

local p = {}

-- get wiki style table local function GetWikiTable(frame) local args = frame.args local p1,p2,p3,p4 = args[1],args[2],args[3],args[4] local tableModule = require('Module:CommonData/' .. p1) local cols = tableModule.GetRawColumns(frame) local rows = tableModule.GetRawTable(frame) local result,resulti = {}, 0

-- header result[#result + 1] = "|-\n" resulti = #result for i,v in ipairs(cols) do       resulti = resulti + 1 result[resulti] = (i == 1 and "! " or "!! ") .. v   end resulti = #result while rows do       for _,v in pairs(rows) do            resulti = resulti + 1 result[resulti] = "\n|-\n" for i2,v2 in pairs(v) do               resulti = resulti + 1 result[resulti] = (i == 1 and "| " or "|| ") .. (tostring(v2) or "") end end rows = tableModule.GetNextRawTable(frame, rows) end result = resulti > 0 and table.concat(result) or ""

--if result and result ~= "" then --   result = frame:preprocess(args.default) --end

return result end

-- CommonData View function p.GetTable(frame) return GetWikiTable(frame) end

return p