Module:HeroList: Difference between revisions

From Heroes of Might and Magic: Olden Era Official Wiki
No edit summary
No edit summary
Line 8: Line 8:
end
end


-- Fonction utilitaire pour récupérer une traduction
-- Fonction utilitaire pour récupérer une traduction via Cargo
local function getTrans(target_id, lang, type, field)
local function getTrans(target_id, lang, type, field)
     field = field or "name"
     field = field or "name"
     if not target_id or target_id == "" then return nil end
     if not target_id or target_id == "" then return nil end
   
     local query = mw.ext.cargo.query("Translation", field, {
     local query = mw.ext.cargo.query("Translation", field, {
         where = string.format("target_id = '%s' AND language = '%s' AND type = '%s'", target_id, lang, type),
         where = string.format("target_id = '%s' AND language = '%s' AND type = '%s'", target_id, lang, type),
         limit = 1
         limit = 1
     })
     })
   
     if not query or #query == 0 then
     if not query or #query == 0 then
         query = mw.ext.cargo.query("Translation", "name", {
         query = mw.ext.cargo.query("Translation", "name", {
Line 29: Line 31:
     local lang = frame.args.language or mw.title.getCurrentTitle().text:match("/(%a%a)$") or "en"
     local lang = frame.args.language or mw.title.getCurrentTitle().text:match("/(%a%a)$") or "en"
      
      
    -- Récupération dynamique des en-têtes via Cargo (Type 'ui')
    local h_port  = getTrans("hero_portrait", lang, "ui") or "Portrait"
    local h_name  = getTrans("hero_name", lang, "ui") or "Name"
    local h_class  = getTrans("hero_class", lang, "ui") or "Class"
    local h_icon  = getTrans("hero_icon", lang, "ui") or "Icon"
    local h_spec  = getTrans("hero_spec", lang, "ui") or "Specialization"
    local h_skills = getTrans("starting_skills", lang, "ui") or "Starting Skills"
    local h_spells = getTrans("starting_spells", lang, "ui") or "Starting Spells"
   
    -- Identification de la faction
     local faction_query = mw.ext.cargo.query("Translation", "target_id", {
     local faction_query = mw.ext.cargo.query("Translation", "target_id", {
         where = string.format("name = '%s' AND type = 'faction'", raw_faction),
         where = string.format("name = '%s' AND type = 'faction'", raw_faction),
Line 35: Line 47:
     local faction_id = (faction_query and #faction_query > 0) and faction_query[1].target_id or raw_faction
     local faction_id = (faction_query and #faction_query > 0) and faction_query[1].target_id or raw_faction
      
      
    -- Requête des héros
     local heroes = mw.ext.cargo.query("Hero", "id, name_sid, class_id, specialization_id, start_skills, start_magics", {
     local heroes = mw.ext.cargo.query("Hero", "id, name_sid, class_id, specialization_id, start_skills, start_magics", {
         where = string.format("faction = '%s' AND id NOT LIKE '%%campaign%%' AND id NOT LIKE '%%tutorial%%' AND id NOT LIKE '%%cm_fun%%'", faction_id)
         where = string.format("faction = '%s' AND id NOT LIKE '%%campaign%%' AND id NOT LIKE '%%tutorial%%' AND id NOT LIKE '%%cm_fun%%'", faction_id)
Line 45: Line 58:
     end)
     end)
      
      
     local html = {'{| class="wikitable sortable" style="width:100%"', '! Portrait !! Nom !! Classe !! Icône !! Spécialisation !! Compétences !! Sorts'}
    -- Construction du tableau
     local html = {'{| class="wikitable sortable" style="width:100%"'}
    table.insert(html, string.format('! %s !! %s !! %s !! %s !! %s !! %s !! %s',
        h_port, h_name, h_class, h_icon, h_spec, h_skills, h_spells))
      
      
     for _, h in ipairs(heroes) do
     for _, h in ipairs(heroes) do
Line 51: Line 67:
         local file_name = getTrans(h.name_sid, 'en', 'hero') or h.id
         local file_name = getTrans(h.name_sid, 'en', 'hero') or h.id
          
          
        -- Récupération du nom traduit ET du nom anglais pour le lien de la classe
         local class_name = getTrans(h.class_id, lang, 'hero_class') or h.class_id
         local class_name = getTrans(h.class_id, lang, 'hero_class') or h.class_id
         local class_name_en = getTrans(h.class_id, 'en', 'hero_class') or h.class_id
         local class_name_en = getTrans(h.class_id, 'en', 'hero_class') or h.class_id
Line 62: Line 77:
          
          
         local spec_name = getTrans(h.specialization_id, lang, 'hero_specialization') or h.specialization_id
         local spec_name = getTrans(h.specialization_id, lang, 'hero_specialization') or h.specialization_id
         local spec_desc = getTrans(h.specialization_id, lang, 'hero_specialization', 'description') or "Pas de description"
         local spec_desc = getTrans(h.specialization_id, lang, 'hero_specialization', 'description') or ""
         local clean_desc = spec_desc:gsub("\n", " "):gsub("\r", " "):gsub('"', '&quot;'):gsub("'", "&#39;"):gsub("<", "&lt;"):gsub(">", "&gt;")
         local clean_desc = spec_desc:gsub("\n", " "):gsub('"', '&quot;'):gsub("'", "&#39;")
          
          
         local spec_icon_data = mw.ext.cargo.query("HeroSpecialization", "icon", {where = string.format("id = '%s'", h.specialization_id), limit = 1})
         local spec_icon_data = mw.ext.cargo.query("HeroSpecialization", "icon", {where = string.format("id = '%s'", h.specialization_id), limit = 1})
Line 70: Line 85:
         local prefix = icon_val:match("^(%a+)_") or "dungeon"
         local prefix = icon_val:match("^(%a+)_") or "dungeon"
         local replacement = faction_map[prefix] or toTitleCase(prefix)
         local replacement = faction_map[prefix] or toTitleCase(prefix)
         local icon_base = icon_val:gsub("^%a+_", replacement .. "_")
         local final_icon_name = toTitleCase(icon_val:gsub("^%a+_", replacement .. "_"):gsub("_", " "))
        local final_icon_name = toTitleCase(icon_base:gsub("_", " "))
          
          
         local spec_icon = string.format("[[File:%s.png|70px|link=]]", final_icon_name)
         local spec_icon = string.format("[[File:%s.png|70px|link=]]", final_icon_name)
Line 99: Line 113:
                     local target_page = (clean_name_en == "Summon Avatar") and "Summon Avatar (Spell)" or clean_name_en
                     local target_page = (clean_name_en == "Summon Avatar") and "Summon Avatar (Spell)" or clean_name_en
                     local icon_name = clean_name_en:gsub("%s+", "_")
                     local icon_name = clean_name_en:gsub("%s+", "_")
                    local link_target = target_page:gsub("%s+", "_")
                     local s_icon = string.format("[[File:%s.png|25px|link=]]", icon_name)
                     local s_icon = string.format("[[File:%s.png|25px|link=]]", icon_name)
                     local s_link = string.format("[[%s/%s|%s]]", link_target, lang, s_name)
                     local s_link = string.format("[[%s/%s|%s]]", target_page:gsub("%s+", "_"), lang, s_name)
                     table.insert(spells_html, s_icon .. " " .. s_link)
                     table.insert(spells_html, s_icon .. " " .. s_link)
                 end
                 end

Revision as of 20:23, 30 May 2026

Description

This module generates an automated table of heroes belonging to a specific faction. It dynamically retrieves localization for hero names, classes, and specializations, and formats the starting skills and spells into a clean, sortable layout.

Usage

The module is invoked via the display function:

{{#invoke:HeroList|display|faction=...|language=...}}

Parameters

Parameter Description Example
faction The name of the faction (as stored in the Translation table). faction=Necropolis
language Forces the Wiki language (if omitted, it detects the page suffix). language=fr

Key Features

  • Dynamic Localization: Translates headers (Name, Class, etc.) and hero-specific data (Names, Skills, Spells) based on the provided language.
  • Automatic Formatting:
    • Displays hero portraits and icons.
    • Formats specializations with tooltips showing descriptions.
    • Lists starting skills and spells as link-lists with icons.
  • Sorting Support: The table uses the sortable class, allowing users to reorder heroes based on columns.
  • Data Cleanup: Automatically filters out campaign, tutorial, and internal testing heroes (e.g., cm_fun).

Implementation Example

To display all heroes of the "Necropolis" faction:

== Necropolis Heroes ==
{{#invoke:HeroList|display|faction=Necropolis}}

Technical Notes

  • The module queries the Hero table and joins data with the Translation table.
  • It uses sortable tables; ensure the MediaWiki "Sortable" extension is active for full functionality.
  • Specialization icons are automatically inferred from the HeroSpecialization table and formatted to match faction naming conventions.

Examples

{{#invoke:HeroList|display|faction=Necropolis}}
Portrait Name Class Icon Specialization Starting Skills Starting Spells
Bulwark Death Knight Built Different
-(+++++)-
Necromancy
Defense
King-of-Kings Death Knight Charismatic
-(+++++)-
Necromancy
Diplomacy
Onkos Death Knight Perfect Puppets
<span title="Skeleton growth in your cities increases by 1.
Under his command, Skeletons gain 1 Speed, 1 Initiative, and 20% HP. Their Attack and Defense increase by 1 for every 3 hero levels, and enemy Skeletons lose an equal amount of Attack and Defense." style="cursor: help;">-(+++++)-
Necromancy
Offense
Kel'Ghul Death Knight Dreadful War
<span title="Dread Knight growth in your cities increases by 1.
Under his command, Dread Knights gain 1 Speed, 1 Initiative, and 20% HP. Their Attack and Defense increase by 1 for every 3 hero levels, and enemy Dread Knights lose an equal amount of Attack and Defense." style="cursor: help;">-(+++++)-
Necromancy
Tactics
Natalida Death Knight Part of a Pack
<span title="Undead Pet growth in your cities increases by 1.
Under her command, Undead Pets gain 1 Speed, 1 Initiative, and 20% HP. Their Attack and Defense increase by 1 for every 3 hero levels, and enemy Undead Pets lose an equal amount of Attack and Defense." style="cursor: help;">-(+++++)-
Necromancy
Scouting
Artorius Veritas Death Knight Drive 'em Crazy
<span title="He starts with the “Masterful Berserk” spell. This version of the spell affects all creatures adjacent to the target.
The cost of this spell is reduced by 1 mana for every 3 hero level(s)." style="cursor: help;">-(+++++)-
Necromancy
Resistance
Masterful Berserk
Marl Death Knight Languid Soil
<span title="He starts with the “Masterful Web” spell. This version of the spell affects all enemies.
While casting this spell, effective Spell Power is increased by 1 for every 2 hero level(s)." style="cursor: help;">-(+++++)-
Necromancy
Logistics
Masterful Web
Tarius Death Knight Undead Legion
-(+++++)-
Necromancy
Zam Death Knight Alchemist
-(+++++)-
Necromancy
Recruitment
Primordial Chaos
Mag Necromancer Arcane Dominion
-(+++++)-
Necromancy
Arcane Magic
Impending Fate
Adahn Necromancer Amnesiac
<span title="Wight growth in your cities increases by 1.
Under his command, Wights gain 1 Speed, 1 Initiative, and 20% HP. Their Attack and Defense increase by 1 for every 3 hero levels, and enemy Wights lose an equal amount of Attack and Defense." style="cursor: help;">-(+++++)-
Necromancy
Battlecraft
Shade Cloak
Ethric Necromancer Tomb-bound Will
<span title="Lich growth in your cities increases by 1.
Under his command, Liches gain 1 Speed, 1 Initiative, and 20% HP. Their Attack and Defense increase by 1 for every 3 hero levels, and enemy Liches lose an equal amount of Attack and Defense." style="cursor: help;">-(+++++)-
Necromancy
Wisdom
Song of Power
Guildmaster Klastor Necromancer Bones Guild
<span title="Graverobber growth in your cities increases by 1.
Under his command, Graverobbers gain 1 Speed, 1 Initiative, and 20% HP. Their Attack and Defense increase by 1 for every 3 hero levels, and enemy Graverobbers lose an equal amount of Attack and Defense." style="cursor: help;">-(+++++)-
Necromancy
Luck
Naira's Veil
Shadespinner Oona Necromancer Shadowmastery
-(+++++)-
Necromancy
Nightshade Magic
Umbral Grip
Laura Necromancer Moldering
<span title="She starts with the “Masterful Despair” spell. This version of the spell affects all types of enemies.
While casting this spell, effective Spell Power is increased by 1 for every 2 hero level(s)." style="cursor: help;">-(+++++)-
Necromancy
Sorcery
Masterful Despair
Lord Rufus Necromancer Wistful Nostalgia
<span title="He starts with the “Masterful Rewind Life” spell. This version of the spell can revive units beyond their original amount.
While casting this spell, effective Spell Power is increased by 1 for every 2 hero level(s)." style="cursor: help;">-(+++++)-
Necromancy
Thaumaturgy
Masterful Rewind Life
Funerella Necromancer Undead Legion
-(+++++)-
Necromancy
Summon Avatar
Basic Summon Avatar
Read Minds
Milossa the Golden Necromancer Wealthy
-(+++++)-
Necromancy
Battle Magic
Fatal Decay


{{#invoke:HeroList|display|faction=Grove|language=ja}}
Portrait Name Class Icon Specialization 開始スキル 開始呪文
イース ウォーデン パスファインダー
-(+++++)-
ざわめき
偵察
槍頭のゴレル ウォーデン 射手
-(+++++)-
ざわめき
攻勢
ジンジャーテール ウォーデン フォーンソング
<span title="自都市における「フォーン」の生産数が1増加する。
指揮下の「フォーン」の素早さとイニシアチブが1、HPが20%増加する。さらに、ヒーローレベル3ごとに攻撃力と防御力が1増加し、敵の「フォーン」は同じ値だけ攻撃力と防御力が減少する。" style="cursor: help;">-(+++++)-
ざわめき
統率
巡礼の老人 ウォーデン 自然の選択
<span title="呪文「マスター:ギロチン」を習得した状態で開始する。このマスター呪文は、同一の対象に対して唱えると、ダメージの増加速度が通常の2倍となる。
また、詠唱中は有効な呪文力がヒーローレベル2ごとに1増加する。" style="cursor: help;">-(+++++)-
ざわめき
戦闘魔法
マスター:ギロチン
オクタヴィア ウォーデン 四葉の馬蹄
-(+++++)-
ざわめき
武運
ニャオワ ウォーデン 魅惑の輝き
-(+++++)-
ざわめき
戦技
バーサーク
ファレオール ウォーデン フクスミラの歩み
<span title="呪文「マスター:火球」を習得した状態で開始する。このマスター呪文は、通常の「火球」よりも広い範囲に効果を及ぼす。
また、詠唱中は有効な呪文力がヒーローレベル2ごとに1増加する。" style="cursor: help;">-(+++++)-
ざわめき マスター:火球
魅惑のシャー ウォーデン カリスマ
-(+++++)-
ざわめき
外交
ダリアおばさん ウォーデン 学びの願い
-(+++++)-
ざわめき
洞察
ヴァトウナ ドルイド 魂の活力
-(+++++)-
ざわめき
叡智
原初の混沌
老ツ=キッシュ ドルイド 最古の樹
<span title="自都市における「薬草術士」の生産数が1増加する。
指揮下の「薬草術士」は素早さとイニシアチブが1、HPが20%増加する。さらに、ヒーローレベル3ごとに攻撃力と防御力が1増加し、敵の「薬草術士」は同じ値だけ攻撃力と防御力が減少する。" style="cursor: help;">-(+++++)-
ざわめき
奇術
活力付与
エアリニエル ドルイド 穏やかな燃えさし
<span title="呪文「マスター:紅蓮の壁」を習得した状態で開始する。このマスター呪文は、通常の「紅蓮の壁」よりも効果の持続時間が2ラウンド長い。
また、詠唱中は有効な呪文力がヒーローレベル2ごとに1増加する。" style="cursor: help;">-(+++++)-
ざわめき
原初魔法
マスター:紅蓮の壁
グレイシア ドルイド 氷撃
<span title="呪文「マスター:氷撃」を習得した状態で開始する。このマスター呪文は、通常の「氷撃」よりもイニシアチブのペナルティが2倍になる。
また、詠唱中は有効な呪文力がヒーローレベル2ごとに1増加する。" style="cursor: help;">-(+++++)-
ざわめき
原初魔法
マスター:氷撃
ヴィム ドルイド ぶちかませ!
<span title="呪文「マスター:降石」を習得した状態で開始する。このマスター呪文で生成された障害物を破壊するには、通常の「降石」よりもダメージを1回多く与える必要がある。
また、詠唱中は有効な呪文力がヒーローレベル2ごとに1増加する。" style="cursor: help;">-(+++++)-
ざわめき
原初魔法
マスター:降石
ハロン ドルイド 轟雷
<span title="呪文「マスター:連鎖雷撃」を習得した状態で開始する。このマスター呪文は、対象間で連鎖するときに減衰するダメージが通常の半分になる。
また、詠唱中は有効な呪文力がヒーローレベル2ごとに1増加する。" style="cursor: help;">-(+++++)-
ざわめき
原初魔法
マスター:連鎖雷撃
エコリリー ドルイド ざわめきの模倣
<span title="呪文「マスター:ミラーコピー」を習得した状態で開始する。このマスター呪文は、敵のクリーチャーを対象にできる。
また、詠唱中は有効な呪文力がヒーローレベル2ごとに1増加する。" style="cursor: help;">-(+++++)-
ざわめき
秘術魔法
マスター:ミラーコピー
サリー ドルイド ざわめきの森の原住民
<span title="自身が召喚した化身は魔法ダメージを無効化する。
「化身召喚」を唱えるとき、有効な呪文力がヒーローレベル2ごとに1増加する。" style="cursor: help;">-(+++++)-
ざわめき
化身召喚
化身召喚(初級)
弱化光線
吟遊詩人 ドルイド 放浪の音楽家
-(+++++)-
ざわめき
魔術知識
エネルギー爆裂

local p = {}

-- Fonction pour mettre la première lettre de chaque mot en majuscule
local function toTitleCase(str)
    return str:gsub("(%a)([%w_]*)", function(first, rest)
        return first:upper() .. rest:lower()
    end)
end

-- Fonction utilitaire pour récupérer une traduction via Cargo
local function getTrans(target_id, lang, type, field)
    field = field or "name"
    if not target_id or target_id == "" then return nil end
    
    local query = mw.ext.cargo.query("Translation", field, {
        where = string.format("target_id = '%s' AND language = '%s' AND type = '%s'", target_id, lang, type),
        limit = 1
    })
    
    if not query or #query == 0 then
        query = mw.ext.cargo.query("Translation", "name", {
            where = string.format("target_id = '%s' AND language = 'en' AND type = '%s'", target_id, type),
            limit = 1
        })
    end
    return (query and #query > 0) and query[1][field] or nil
end

function p.display(frame)
    local raw_faction = frame.args.faction
    local lang = frame.args.language or mw.title.getCurrentTitle().text:match("/(%a%a)$") or "en"
    
    -- Récupération dynamique des en-têtes via Cargo (Type 'ui')
    local h_port   = getTrans("hero_portrait", lang, "ui") or "Portrait"
    local h_name   = getTrans("hero_name", lang, "ui") or "Name"
    local h_class  = getTrans("hero_class", lang, "ui") or "Class"
    local h_icon   = getTrans("hero_icon", lang, "ui") or "Icon"
    local h_spec   = getTrans("hero_spec", lang, "ui") or "Specialization"
    local h_skills = getTrans("starting_skills", lang, "ui") or "Starting Skills"
    local h_spells = getTrans("starting_spells", lang, "ui") or "Starting Spells"
    
    -- Identification de la faction
    local faction_query = mw.ext.cargo.query("Translation", "target_id", {
        where = string.format("name = '%s' AND type = 'faction'", raw_faction),
        limit = 1
    })
    local faction_id = (faction_query and #faction_query > 0) and faction_query[1].target_id or raw_faction
    
    -- Requête des héros
    local heroes = mw.ext.cargo.query("Hero", "id, name_sid, class_id, specialization_id, start_skills, start_magics", {
        where = string.format("faction = '%s' AND id NOT LIKE '%%campaign%%' AND id NOT LIKE '%%tutorial%%' AND id NOT LIKE '%%cm_fun%%'", faction_id)
    })
    
    table.sort(heroes, function(a, b)
        local numA = tonumber(a.id:match("(%d+)$")) or 0
        local numB = tonumber(b.id:match("(%d+)$")) or 0
        return numA < numB
    end)
    
    -- Construction du tableau
    local html = {'{| class="wikitable sortable" style="width:100%"'}
    table.insert(html, string.format('! %s !! %s !! %s !! %s !! %s !! %s !! %s', 
        h_port, h_name, h_class, h_icon, h_spec, h_skills, h_spells))
    
    for _, h in ipairs(heroes) do
        local name = getTrans(h.name_sid, lang, 'hero') or h.name_sid
        local file_name = getTrans(h.name_sid, 'en', 'hero') or h.id
        
        local class_name = getTrans(h.class_id, lang, 'hero_class') or h.class_id
        local class_name_en = getTrans(h.class_id, 'en', 'hero_class') or h.class_id
        
        -- SPÉCIALISATION
        local faction_map = {
            ["human"] = "Temple", ["necro"] = "Necropolis", ["nature"] = "Grove",
            ["unfrozen"] = "Schism", ["demon"] = "Hive", ["dungeon"] = "Dungeon"
        }
        
        local spec_name = getTrans(h.specialization_id, lang, 'hero_specialization') or h.specialization_id
        local spec_desc = getTrans(h.specialization_id, lang, 'hero_specialization', 'description') or ""
        local clean_desc = spec_desc:gsub("\n", " "):gsub('"', '&quot;'):gsub("'", "&#39;")
        
        local spec_icon_data = mw.ext.cargo.query("HeroSpecialization", "icon", {where = string.format("id = '%s'", h.specialization_id), limit = 1})
        local icon_val = (spec_icon_data and #spec_icon_data > 0) and spec_icon_data[1].icon or ""
        
        local prefix = icon_val:match("^(%a+)_") or "dungeon"
        local replacement = faction_map[prefix] or toTitleCase(prefix)
        local final_icon_name = toTitleCase(icon_val:gsub("^%a+_", replacement .. "_"):gsub("_", " "))
        
        local spec_icon = string.format("[[File:%s.png|70px|link=]]", final_icon_name)
        local spec_formatted = string.format("'''%s'''<br><span title=\"%s\" style=\"cursor: help;\"><u>''-(+++++)-''</u></span>", spec_name, clean_desc)
        
        -- COMPÉTENCES
        local skills_html = {}
        if h.start_skills then
            for skill_id in string.gmatch(h.start_skills, "([^,]+)") do
                local s_name = getTrans(skill_id, lang, 'skill') or skill_id
                local s_name_en = getTrans(skill_id, 'en', 'skill') or skill_id
                local target_page = (s_name_en == "Summon Avatar") and "Summon Avatar (Skill)" or s_name_en
                local s_icon = string.format("[[File:Skill_%s.png|25px|link=]]", s_name_en:gsub("%s+", "_"))
                local s_link = string.format("[[%s/%s|%s]]", target_page:gsub("%s+", "_"), lang, s_name)
                table.insert(skills_html, s_icon .. " " .. s_link)
            end
        end
        
        -- SORTS
        local spells_html = {}
        if h.start_magics then
            for spell_id in string.gmatch(h.start_magics, "([^,]+)") do
                if spell_id ~= "change_use_necromancy" then
                    local s_name = getTrans(spell_id, lang, 'spell') or spell_id
                    local s_name_en = getTrans(spell_id, 'en', 'spell') or spell_id
                    local clean_name_en = s_name_en:gsub("^Masterful%s+", ""):gsub("^Basic%s+", "")
                    local target_page = (clean_name_en == "Summon Avatar") and "Summon Avatar (Spell)" or clean_name_en
                    local icon_name = clean_name_en:gsub("%s+", "_")
                    local s_icon = string.format("[[File:%s.png|25px|link=]]", icon_name)
                    local s_link = string.format("[[%s/%s|%s]]", target_page:gsub("%s+", "_"), lang, s_name)
                    table.insert(spells_html, s_icon .. " " .. s_link)
                end
            end
        end
        
        -- CONSTRUCTION DE LA LIGNE
        table.insert(html, "|-")
        table.insert(html, string.format('| [[File:%s.png|70px]]', file_name))
        table.insert(html, string.format('| [[%s/%s|%s]]', file_name, lang, name))
        table.insert(html, string.format('| [[%s/%s|%s]]', class_name_en, lang, class_name))
        table.insert(html, "| " .. spec_icon)
        table.insert(html, "| " .. spec_formatted)
        table.insert(html, "| " .. table.concat(skills_html, "<br>"))
        table.insert(html, "| " .. table.concat(spells_html, "<br>"))
    end
    
    table.insert(html, "|}")
    return table.concat(html, "\n")
end

return p