Modul:Warning
Qiyofa
This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
Ushbu modul oddiygina Module:Errorga o'xshash barcha ogohlantirish xabarlarining formatlanishini birlashtiradi. Hozirda bu oddiy matn, lekin muhokama sahifasida muhokama qilingandan soʻng maxsus formatlash qoʻllanilishi mumkin. Tahrirni oldindan ko'rishda ogohlantirishlar oldindan ko'rish ustida ko'rsatiladi.
Ishlatilishi
[manbasini tahrirlash]local warn = require('Module:Warning')
warn("Message")
warn(("TypeWarning: %s"):format(warning), level)
Yana qarang
[manbasini tahrirlash]local libraryUtil = require('libraryUtil')
local wrapper = "%s" -- wikitext formatting
local msg_loc = "Lua warning in %s at line %d: %s."
local msg = "Lua warning: %s."
return function (message, level)
libraryUtil.checkType('warn', 2, level, 'number', true)
level = level or 1
if level > 0 then
local _, location = pcall(error, '', level+2)
if location ~= '' then
location = mw.text.split(location:sub(1,-3), ':%f[%d]')
message = msg_loc:format(location[1], location[2], message)
else
message = msg:format(message)
end
else
message = msg:format(message)
end
mw.addWarning(wrapper:format(message))
end