Module:Infobox

From Runnina
Revision as of 08:20, 8 July 2025 by Administrator (talk | contribs) (Created page with "-- Module:Infobox -- A simplified Lua module to generate infobox tables for country data. local p = {} -- Function to generate a single row in the infobox local function makeRow(label, value) if value and value ~= '' then return '|- \n! scope="row" | ' .. label .. ' \n| ' .. value .. '\n' else return '' -- Return empty string if value is nil or empty end end -- Main function to build the infobox function p.main(frame) local args = frame...")
Jump to navigation Jump to search

{{#ifeq:Infobox|doc|{{#if:|Template:Pp}}|{{#switch:

 {{#if:
 |     
 | {{#ifeq:Module|Module
   | module
   | other
   }}
 }}

| module = Template:Ombox{{#if:|| {{#ifeq: Module:Infobox | Sandbox

    | 
    | {{#switch: Infobox
        | doc | sandbox =
        | {{#ifeq:  | true 
            |  
            | {{#switch: protected
                | pre-alpha | prealpha | pa | experimental = 
                | alpha | a = 
                | beta | b = 
                | release | r | general | g | stable = 
                | broken | br | unstable = 
              }}
          }}
      }}
   }}

}}Template:Module rating/protected | other | #default = Template:Error }}}}

Lua error in Module:TNT at line 159: Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:I18n/Uses TemplateStyles.tab.

Module:Infobox is a module that implements the Template:Tl template. Please see the template page for usage instructions.

{{#ifeq:Infobox|sandbox|| }}


-- Module:Infobox
-- A simplified Lua module to generate infobox tables for country data.

local p = {}

-- Function to generate a single row in the infobox
local function makeRow(label, value)
    if value and value ~= '' then
        return '|- \n! scope="row" | ' .. label .. ' \n| ' .. value .. '\n'
    else
        return '' -- Return empty string if value is nil or empty
    end
end

-- Main function to build the infobox
function p.main(frame)
    local args = frame.args

    -- Start the infobox table
    local infobox_output = '{| class="infobox"\n'

    -- Title/Caption
    infobox_output = infobox_output .. '|+ ' .. (args.official_name or 'Country Name') .. '\n'

    -- Map Image Section
    if args.map_image and args.map_image ~= '' then
        local map_caption_text = ''
        if args.map_caption and args.map_caption ~= '' then
            map_caption_text = '<div class="infobox-map-caption">Official Borders & Territories Recognized.<br>' .. args.map_caption .. '</div>'
        end
        infobox_output = infobox_output ..
            '|- \n| colspan="2" style="text-align: center; padding: 0.5em 0;" | \n' ..
            '[[File:' .. args.map_image .. '|250px|center|alt=' .. (args.map_caption or 'Official Map') .. ']]\n' ..
            map_caption_text .. '\n'
    end

    -- Add rows based on provided parameters
    infobox_output = infobox_output .. makeRow('Native Name', args.native_name)
    infobox_output = infobox_output .. makeRow('Motto', args.motto)
    infobox_output = infobox_output .. makeRow('Capital', args.capital)
    infobox_output = infobox_output .. makeRow('Largest Cities', args.largest_cities)
    infobox_output = infobox_output .. makeRow('Religious Identification', args.religious_identification)
    infobox_output = infobox_output .. makeRow('Demonym', args.demonym)
    infobox_output = infobox_output .. makeRow('Ethnic Groups', args.ethnic_groups)
    infobox_output = infobox_output .. makeRow('Government', args.government)
    infobox_output = infobox_output .. makeRow('Chambers', args.chambers)
    infobox_output = infobox_output .. makeRow('Laws', args.laws)
    infobox_output = infobox_output .. makeRow('Independence', args.independence)
    infobox_output = infobox_output .. makeRow('Head of the State', args.head_of_state)
    infobox_output = infobox_output .. makeRow('Power Status', args.power_status)
    infobox_output = infobox_output .. makeRow('Common Background', args.common_background)

    -- GDP section (nested list)
    if (args.gdp_total and args.gdp_total ~= '') or (args.gdp_per_capita and args.gdp_per_capita ~= '') then
        infobox_output = infobox_output .. '|- \n! scope="row" | GDP \n| \n'
        if args.gdp_total and args.gdp_total ~= '' then
            infobox_output = infobox_output .. ': Total: ' .. args.gdp_total .. '\n'
        end
        if args.gdp_per_capita and args.gdp_per_capita ~= '' then
            infobox_output = infobox_output .. ': per Capita: ' .. args.gdp_per_capita .. '\n'
        end
    end

    infobox_output = infobox_output .. makeRow('HDI', args.hdi)
    infobox_output = infobox_output .. makeRow('Currency', args.currency)
    infobox_output = infobox_output .. makeRow('Abbreviated Codex', args.codex)

    -- End the infobox table
    infobox_output = infobox_output .. '|}'

    return infobox_output
end

return p