Module:OOO/Variants: Difference between revisions
Created page with "local DATA = require('Module:OOO/Data') local p = {} local function esc(s) return mw.text.nowiki(tostring(s or '')) end local function label_for(domain, art, given) if given and given ~= '' then return given end local rec = DATA.get(domain, art) or {} return rec.displayName or tostring(art) end -- Forward a small set of per-tab overrides if present, like image3=..., description2=... local passthrough_keys = { 'image', 'description', 'dimensions', 'class' } func..." |
No edit summary |
||
Line 1: | Line 1: | ||
local DATA = require('Module:OOO/Data') | local DATA = require('Module:OOO/Data') | ||
local p = {} | local p = {} | ||
local function label_for(domain, art, given) | local function label_for(domain, art, given) | ||
Line 10: | Line 8: | ||
end | end | ||
-- | -- allow per-tab overrides like image3=..., description2=..., dimensions4=... | ||
local passthrough_keys = { 'image', 'description', 'dimensions', 'class' } | local passthrough_keys = { 'image', 'description', 'dimensions', 'class' } | ||
function p.tabs(frame) | function p.tabs(frame) | ||
local args = (frame:getParent() or frame).args or {} | local args = (frame:getParent() or frame).args or {} | ||
local domain = args.domain or args.type or 'Buildings' | local domain = args.domain or args.type or 'Buildings' | ||
local align | local align = args.align or 'right' | ||
local entries, i = {}, 1 | local entries, i = {}, 1 | ||
Line 25: | Line 23: | ||
local label = label_for(domain, art, args['label'..i] or args['name'..i]) | local label = label_for(domain, art, args['label'..i] or args['name'..i]) | ||
-- Build args for | -- Build args for OOOInfoBox | ||
local ibx = { art = art, align = align, type = domain } | local ibx = { art = art, align = align, type = domain } | ||
for _, key in ipairs(passthrough_keys) do | for _, key in ipairs(passthrough_keys) do | ||
Line 33: | Line 31: | ||
local content = frame:expandTemplate{ title = 'OOOInfoBox', args = ibx } | local content = frame:expandTemplate{ title = 'OOOInfoBox', args = ibx } | ||
entries[#entries+1] = | |||
-- Collect TabberNeue wikitext part: <label>=<content> | |||
entries[#entries+1] = string.format('%s=\n%s\n', label, content) | |||
i = i + 1 | i = i + 1 | ||
end | end | ||
Line 41: | Line 41: | ||
end | end | ||
-- Force the tabber tag to be parsed by MediaWiki | |||
local inner = table.concat(entries, '|-|\n') | |||
local tabber = frame:extensionTag('tabber', inner) | |||
-- | -- Wrap & attach styles | ||
local html = '<div class="ooo-infobox-tabwrap">' .. tabber .. '</div>' | |||
html = html .. frame:extensionTag('templatestyles', '', { src = 'Template:OOOInfoBoxTabber/styles.css' }) | html = html .. frame:extensionTag('templatestyles', '', { src = 'Template:OOOInfoBoxTabber/styles.css' }) | ||
return html | return html |