ผลต่างระหว่างรุ่นของ "มอดูล:Infobox"

จาก Roleplay Wiki
ไปยังการนำทาง ไปยังการค้นหา
แก้ความเข้ากันได้ของกล่องข้อมูล
ป้ายระบุ: ถูกแทน
ทดสอบการเรียกมอดูล
ป้ายระบุ: ถูกแทน
 
(ไม่แสดง 3 รุ่นระหว่างกลางโดยผู้ใช้คนเดียวกัน)
บรรทัดที่ 1: บรรทัดที่ 1:
local p = {}
local p={}
local function esc(v) return v or '' end
function p.infoboxTemplate(frame) return '<table class="infobox"><tr><th>ทดสอบ</th></tr></table>' end
function p.infoboxTemplate(frame)
p.infobox=p.infoboxTemplate
  local a = frame.args
  local root = mw.html.create('table'):addClass('infobox')
  local title = a['honorific-prefix'] or ''
  if a.name and a.name ~= '' then title = title .. a.name end
  if a['honorific-suffix'] and a['honorific-suffix'] ~= '' then title = title .. ' ' .. a['honorific-suffix'] end
  if title ~= '' then root:tag('caption'):addClass('infobox-title'):wikitext(title):done() end
  if a.image and a.image ~= '' then
    local row=root:tag('tr'); row:tag('td'):attr('colspan','2'):css('text-align','center'):wikitext('[[ไฟล์:'..a.image..'|กลาง|'..(a.image_size or a.imagesize or '220px')..']]'):done(); row:done()
  end
  if a.caption and a.caption ~= '' then local row=root:tag('tr'); row:tag('td'):attr('colspan','2'):css('text-align','center'):wikitext(a.caption):done(); row:done() end
  local keys={'order','monarch','term_start','term_end','predecessor','successor','birth_date','birth_place','party','spouse','alma_mater','religion'}
  for _,k in ipairs(keys) do if a[k] and a[k] ~= '' then local row=root:tag('tr'); row:tag('th'):wikitext(k):done(); row:tag('td'):wikitext(a[k]):done(); row:done() end end
  for i=1,20 do local office=a['office'..i]; if office and office ~= '' then local row=root:tag('tr'); row:tag('th'):wikitext(office):done(); row:tag('td'):wikitext((a['term_start'..i] or '') .. (a['term_end'..i] and '<br>'..a['term_end'..i] or '')):done(); row:done() end end
  return tostring(root)
end
p.infobox = p.infoboxTemplate
return p
return p

รุ่นแก้ไขปัจจุบันเมื่อ 21:59, 29 ตุลาคม 2569

เอกสารการใช้งานสำหรับมอดูลนี้อาจสร้างขึ้นที่ มอดูล:Infobox/doc

local p={}
function p.infoboxTemplate(frame) return '<table class="infobox"><tr><th>ทดสอบ</th></tr></table>' end
p.infobox=p.infoboxTemplate
return p