Module:Covers

From Heartbound Wiki

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

-- <nowiki>
local p = {}

local faces = {
    ['Baron'] = 'sleeping'
}

function p.main(frame)
    local html = mw.html.create('div'):addClass('cover-image__wrapper')
    for k, v in pairs(frame:getParent().args) do
        local name
        local class = ''
        if tonumber(k) then
            name = v
        else
            name = k
        end
        if v:len() > 6 then
            class = 'small'
        end
        html:tag('div')
                :addClass('cover-image')
                :tag('div')
                    :addClass('cover-image__image')
                    :wikitext('[[File:' .. name .. ' face ' .. (faces[name] or 'neutral') .. '.gif|113px|link=' .. name .. ']]')
                :done()
                :tag('div')
                    :addClass('cover-image__name')
                    :addClass(class)
                    :wikitext('[[' .. name .. '|' .. v .. ']]')
                :done()
            :done()
    end
    return tostring(html:done())
end

return p