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',
     'dataWrapperOpen',
    'organizations',
    'people',
    'laws',
    'documents',
    'geoTlds',
    'meetings',
    'nra',
    'resources',
    'dataWrapperClose',
     'wrapperClose',
     'wrapperClose',
     'categories',
     'categories',
Line 474: Line 483:
}
}


-- Data columns "super block"
-- Data wrapper blocks
template.config.blocks.dataColumns = {
template.config.blocks.dataWrapperOpen = {
     feature = 'fullPage',
     feature = 'fullPage',
     render = function(template, args)
     render = function() return '<div class="country-hub-data-container">' end
        local dataBlocks = {}
}
        local dataBlockNames = {
template.config.blocks.dataWrapperClose = {
            'organizations', 'people', 'laws', 'documents',
    feature = 'fullPage',
            'geoTlds', 'meetings', 'nra', 'resources'
    render  = function() return '</div>' end
        }
 
        for _, blockName in ipairs(dataBlockNames) do
            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 552: Line 531:
     return ErrorHandling.protect(
     return ErrorHandling.protect(
         errorContext, "render",
         errorContext, "render",
         function() return template:render(frame) end,
         function() return template.render(frame) end,
         ErrorHandling.getMessage("TEMPLATE_RENDER_ERROR"),
         ErrorHandling.getMessage("TEMPLATE_RENDER_ERROR"),
         frame
         frame