Modül:RolBox
Bu modül için bir Modül:RolBox/belge belgelendirmesi oluşturabilirsiniz
local p = {}
local function splitList(str)
local t = {}
for item in string.gmatch(str, "([^,]+)") do
table.insert(t, mw.text.trim(item))
end
return t
end
function p.render(frame)
local args = frame:getParent().args
local isim = args["isim"] or ""
local gorev = args["gorev"] or ""
local aciklama = args["aciklama"] or ""
local kritik = args["kritik"] or ""
local ikinci = args["ikinci"] or ""
local simgeler = args["simgeler"] or ""
local kritikList = kritik ~= "" and splitList(kritik) or {}
local ikinciList = ikinci ~= "" and splitList(ikinci) or {}
local simgeList = simgeler ~= "" and splitList(simgeler) or {}
-- kritik badge
local kritik_html = ""
for _,v in ipairs(kritikList) do
kritik_html = kritik_html .. '<span class="fm-pill fm-pill-critical">' .. v .. '</span>'
end
-- ikinci badge
local ikinci_html = ""
for _,v in ipairs(ikinciList) do
ikinci_html = ikinci_html .. '<span class="fm-pill fm-pill-secondary">' .. v .. '</span>'
end
-- simgeler
local simge_html = ""
for _,v in ipairs(simgeList) do
simge_html = simge_html .. '<span class="fm-icon">' .. v .. '</span>'
end
-- açıklama
local aciklama_html = ""
if aciklama ~= "" then
aciklama_html = string.format('<div class="fm-desc">%s</div>', aciklama)
end
-- ikinci alan varsa blok
local ikinci_block = ""
if ikinci ~= "" then
ikinci_block = string.format([[
<tr>
<th>İkincil Alanlar</th>
<td>%s</td>
</tr>
]], ikinci_html)
end
return string.format([[
<div class="fm-rolebox-pro">
<table class="fm-table">
<tr>
<th>Rol</th>
<td class="fm-name">%s</td>
</tr>
<tr>
<th>Görev</th>
<td class="fm-tag">%s</td>
</tr>
%s
<tr>
<th>Kritik Alanlar</th>
<td>%s</td>
</tr>
<tr>
<th>Simgeler</th>
<td>%s</td>
</tr>
</table>
%s
</div>
]],
isim,
gorev,
ikinci_block,
kritik_html,
simge_html,
aciklama_html
)
end
return p