உள்ளடக்கத்துக்குச் செல்

Module:Error

கட்டற்ற கலைக்களஞ்சியமான விக்கிப்பீடியாவில் இருந்து.
AntanO (பேச்சு | பங்களிப்புகள்) பயனரால் செய்யப்பட்ட 17:43, 12 சனவரி 2016 அன்றிருந்தவாரான திருத்தம் (en:Module:Error இலிருந்து ஒரு திருத்தம்: File namespace)
(வேறுபாடு) ← பழைய திருத்தம் | புதிய திருத்தத்தைப் பார்க்கவும். (வேறுபாடு) | புதிய திருத்தம் → (வேறுபாடு)

This module creates an html message with class "error". It is a replacement for {{error}} - please see the documentation page there for usage instructions.


-- This module implements {{error}}.

local p = {}

local function _error(args)
    local tag = mw.ustring.lower(tostring(args.tag))

    -- Work out what html tag we should use.
    if not (tag == 'p' or tag == 'span' or tag == 'div') then
        tag = 'strong'
    end

    -- Generate the html.
    return tostring(mw.html.create(tag)
        :addClass('error')
        :wikitext(tostring(args.message or args[1] or error('no message specified', 2)))
    )
end

function p.error(frame)
    local args
    if type(frame.args) == 'table' then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = frame.args
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
    end
    -- if the message parameter is present but blank, change it to nil so that Lua will
    -- consider it false.
    if args.message == "" then
        args.message = nil
    end
    return _error(args)
end

return p
"https://ta.wikipedia.org/w/index.php?title=Module:Error&oldid=2001262" இலிருந்து மீள்விக்கப்பட்டது