Module:T-CountryHub: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 146: | Line 146: | ||
'intro', | 'intro', | ||
'overview', | 'overview', | ||
'dataColumns', | |||
'wrapperClose', | 'wrapperClose', | ||
'categories', | 'categories', | ||
| Line 472: | Line 472: | ||
return renderSection('resources:' .. args.has_country, params, {'Resources'}) | return renderSection('resources:' .. args.has_country, params, {'Resources'}) | ||
end, | end, | ||
} | |||
-- Data columns "super block" | |||
template.config.blocks.dataColumns = { | |||
feature = 'fullPage', | |||
render = function(template, args) | |||
local dataBlocks = {} | |||
local dataBlockNames = { | |||
'organizations', 'people', 'laws', 'documents', | |||
'geoTlds', 'meetings', 'nra', 'resources' | |||
} | |||
for _, blockName in ipairs(dataBlockNames) do | |||
-- We need to check if the feature for the block is enabled before rendering | |||
if template.features[blockName] then | |||
local blockContent = template:renderBlock(blockName, args) | |||
if blockContent and blockContent ~= '' then | |||
table.insert(dataBlocks, blockContent) | |||
end | |||
end | |||
end | |||
if #dataBlocks == 0 then | |||
return '' | |||
end | |||
local columns = {'', '', ''} | |||
for i, blockContent in ipairs(dataBlocks) do | |||
local colIndex = (i - 1) % 3 + 1 | |||
columns[colIndex] = columns[colIndex] .. blockContent | |||
end | |||
local dataContainer = html.create('div'):addClass('country-hub-data-container') | |||
for _, colContent in ipairs(columns) do | |||
if colContent ~= '' then | |||
dataContainer:tag('div'):addClass('country-hub-column'):wikitext(colContent):done() | |||
end | |||
end | |||
return tostring(dataContainer) | |||
end | |||
} | } | ||
| Line 507: | Line 548: | ||
return cats | return cats | ||
end) | end) | ||
-- Render entry point; wraps the Blueprint rendering process with error protection | -- Render entry point; wraps the Blueprint rendering process with error protection | ||