Module:Navigation: Difference between revisions
From PC Gaming Shelter
Created page with "local p = {} local function renderThumb(row) local caption, img, target = row[1], row[2], row[3] if not target then target = caption end local html = mw.html.create() html:tag('div') :tag('div'):attr('data-bg', img):wikitext(string.format(%s, target, caption)):done() :tag('div'):wikitext(string.format(%s, target, caption)):done() :done() return html end function p.thumbwall(frame) local args = frame:getParent().args local title = ar..." |
No edit summary |
||
| Line 30: | Line 30: | ||
end | end | ||
local wallContent = | local wallContent = '' | ||
for _, row in ipairs(thumbTable) do | for _, row in ipairs(thumbTable) do | ||
wallContent = wallContent .. renderThumb(row) | |||
end | end | ||
Revision as of 12:04, 15 March 2026
Documentation for this module may be created at Module:Navigation/doc
local p = {}
local function renderThumb(row)
local caption, img, target = row[1], row[2], row[3]
if not target then
target = caption
end
local html = mw.html.create()
html:tag('div')
:tag('div'):attr('data-bg', img):wikitext(string.format([[%s|%s]], target, caption)):done()
:tag('div'):wikitext(string.format([[%s|%s]], target, caption)):done()
:done()
return html
end
function p.thumbwall(frame)
local args = frame:getParent().args
local title = args[1] or 'Navigate'
local thumbs = args[2]
if not thumbs then return end
local thumbTable = {}
for line in thumbs:gmatch("[^\r\n]+") do
-- Split into three parts: img, caption, target
local img, caption, target = line:match("^%s*(.-)%s*;%s*(.-)%s*;%s*(.-)%s*$")
if img and caption and target then
table.insert(thumbTable, { img, caption, target })
end
end
local wallContent = ''
for _, row in ipairs(thumbTable) do
wallContent = wallContent .. renderThumb(row)
end
local html = mw.html.create()
local wall = html:tag('div'):addClass('card')
:tag('div'):addClass('card-header'):wikitext(title):done()
:tag('div'):addClass('card-body'):wikitext(wallContent)
:done()
return wall
end
return p
