Module:Infobox

From Zelda Dungeon Wiki
Revision as of 02:17, November 16, 2020 by Locke (talk | contribs) (change label class to zdw-label to distinguish from bootstrap)
Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.

Documentation for this module may be created at Module:Infobox/doc

local p = require( 'Module:Box' )

function p.hostile( frame )
    return tostring( p._infobox( 'hostile', frame:getParent().args ) )
end

function p.dungeon( frame )
    return tostring( p._infobox( 'dungeon', frame:getParent().args ) )
end

function p.location( frame )
    return tostring( p._infobox( 'location', frame:getParent().args ) )
end

function p.character( frame )
    return tostring( p._infobox( 'character', frame:getParent().args ) )
end

function p.item( frame )
    return tostring( p._infobox( 'item', frame:getParent().args ) )
end

function p.knowledge( frame )
    return tostring( p._infobox( 'knowledge', frame:getParent().args ) )
end

function p.meta( frame )
    return tostring( p._infobox( 'meta', frame:getParent().args ) )
end

function p._infobox( type, args )
    -- translate "name" from infobox template to "title" box parameter
    local boxargs = args
    boxargs.title = args.name
    boxargs.class = 'infobox infobox-' .. type

    -- construct box
    local box, content = p._light( boxargs )

    -- add logo (TODO better way of loading images?)
    if args.logo then
        content:tag( 'div' )
            :addClass( 'zdw-label center' )
            :wikitext( args.logo )
    end

    -- add image/boxart (TODO better way of loading images?)
    if args.boxart or args.image then
        content:tag( 'div' )
            :addClass( 'center' )
            :wikitext( args.boxart or args.image )
    end

    -- TODO table

    return tostring( box )
end

return p