Module:RoboInfo: Difference between revisions

From Little Tail Wiki
Jump to navigationJump to search
Created page with "local capiunto = require 'capiunto' local p = {} function p.main(frame) local args = frame:getParent().args -- Set header style, defaulting to 'background-color:grey' if not provided local headerStyle = args.headerstyle and args.headerstyle ~= '' and string.format('background-color:%s;', args.headerstyle) or 'background-color:grey;' -- Create the infobox local retval = capiunto.create({ title = tostring(mw.title.getCurrentTitle()),..."
 
No edit summary
 
Line 26: Line 26:
     -- Add rows only for fields that are not empty
     -- Add rows only for fields that are not empty
     local rows = {
     local rows = {
        { 'Japanese Name', args.jpname },
        { 'Romanized Name', args.romanname },
        { 'Namesake', args.namesake },
         { 'Pilot', args.pilot },
         { 'Pilot', args.pilot },
         { 'Creator', args.creator },
         { 'Creator', args.creator },
        { 'First Appearance', args.firstappearance },
        { 'Last Appearance', args.lastappearance },
     }
     }



Latest revision as of 20:58, 19 February 2025

Module:RoboInfo

An example image (IMAGE REQUIRED)
Info.
Japanese Name Optional
Romanized Name Optional
Namesake Optional
Pilot Optional
Creator Optional
First Appearance Optional
Last Appearance Optional

The RoboInfo infobox is dedicated to quickly listing off basic information about the article's featured Robo/mecha.

Infoboxes are put together via Capiunto, which calls upon a Lua-based module. This keeps infoboxes clean and easy to form.

In source editor, excluding any optional row will make that row not render. Leaving out any required fields will throw an error over the page. HTML tags can be used within the infobox if necessary.

Usage

{{RoboInfo
| headerstyle = (defaults to background-color:grey)
| image       = [[File:Waffle.png|200px]]
| caption     = An example image (IMAGE REQUIRED)
| ("Bio.")
| jpname              = Optional
| romanname           = Optional
| namesake            = Optional
| pilot               = Optional
| creator             = Optional
| firstappearance     = Optional
| lastappearance      = Optional
}}

local capiunto = require 'capiunto'

local p = {}

function p.main(frame)
    local args = frame:getParent().args

    -- Set header style, defaulting to 'background-color:grey' if not provided
    local headerStyle = args.headerstyle and args.headerstyle ~= '' and
        string.format('background-color:%s;', args.headerstyle) or 'background-color:grey;'

    -- Create the infobox
    local retval = capiunto.create({
        title = tostring(mw.title.getCurrentTitle()),
        headerStyle = headerStyle,
    })

    -- Add image and caption
    if args.image then
        retval:addImage(args.image, args.caption or '')
    end

    -- Add a general header
    retval:addHeader('Info.')

    -- Add rows only for fields that are not empty
    local rows = {
        { 'Japanese Name', args.jpname },
        { 'Romanized Name', args.romanname },
        { 'Namesake', args.namesake },
        { 'Pilot', args.pilot },
        { 'Creator', args.creator },
        { 'First Appearance', args.firstappearance },
        { 'Last Appearance', args.lastappearance },
    }

    for _, row in ipairs(rows) do
        local label, value = row[1], row[2]
        if value and value ~= '' then
            retval:addRow(label, value)
        end
    end

    return retval
end

return p