Path of Exile Wiki

Wiki поддерживается сообществом, поэтому подумайте над тем, чтобы внести свой вклад.

ПОДРОБНЕЕ

Path of Exile Wiki
Advertisement
Template info icon Документация модуля[просмотр] [править] [история] [очистить]

Реализует {{error}}.

-------------------------------------------------------------------------------
-- 
--                               Module:Error
-- 
-- This module implements Template:Error
-------------------------------------------------------------------------------

local cfg = {}

cfg.i18n = {}

cfg.i18n.errors = {
    no_message = 'No message specified.',
}

cfg.tag = 'strong'

-- ----------------------------------------------------------------------------
-- Main function
-- ----------------------------------------------------------------------------

local function _main(args)
    args.message = args.message or args[1]
    if not args.message or args.message == '' then
        error(cfg.i18n.errors.no_message, 2)
    end
    local html = mw.html.create(cfg.tag)
        :addClass('error')
        :wikitext(tostring(args.message))
    return tostring(html)
end

-- ----------------------------------------------------------------------------
-- Exported functions
-- ----------------------------------------------------------------------------

local p = {}

function p.main(frame)
    local args
    if type(frame.args) == 'table' then
        -- Called via #invoke, so use the args that were passed into the 
        -- template.
        args = frame.args
    else
        -- Called from another module or from the debug console, so assume args 
        -- are passed in directly.
        args = frame
    end
    return _main(args)
end

p.error = p.main

return p
Advertisement