local p = {}
local pframe

local function getArg(ar)
    if pframe.args[ar] and pframe.args[ar] ~= "" then
        return pframe.args[ar]
    else
        return ""
    end
end

function p.td2(frame)
    local roo = {}
    local list = { y = "سنوات", c = "أندية", m = "مباريات", g = "أهداف" }
    pframe = frame.getParent(frame)

    local Table = mw.html.create("table")
    local ii = 1
    while true do
        local years = list.y .. ii  											--'سنوات' .. ii
        local clubs = list.c .. ii  											--'أندية' .. ii
        local matchs = list.m .. ii 											-- 'مباريات' .. ii
        local goals = list.g .. ii  											--'أهداف' .. ii
        if pframe.args[clubs] or pframe.args[years] then
            if getArg(clubs) or getArg(years) then
                local goals_r = "-"
                if getArg(goals) then
                    goals_r = pframe.args[goals]
                end
                local tr = mw.html.create("tr")
                -- tr:tag("td"):css('background-color', '#f2f2f2'):tag("span"):addClass('nowrap'):wikitext(pframe.args[years])
                tr:tag("td"):addClass("nowrap"):css("background-color", "#f2f2f2"):tag("span"):wikitext(
                    pframe.args[years]
                )
                tr:tag("td"):tag("span"):wikitext(pframe.args[clubs])
                tr:tag("td"):tag("span"):wikitext(getArg(matchs))
                tr:tag("td"):tag("span"):wikitext("(" .. goals_r .. ")")
                table.insert(roo, tostring(tr) .. "\n")
            end
        else
            break
        end
        ii = ii + 1
    end
    OP = table.concat(roo)
    return tostring(OP)
end

return p