વિભાગ:ભૂલકાઢ
Appearance
This module is used to debug templates and other modules, and to help track down problems or incorrect usage.
dump
[ફેરફાર કરો]dump(value)
Converts any value (except for functions) into a string representation. The string is formatted as Lua syntax, so you should be able to take the output of this function and insert it back into a Lua module. Tables are processed recursively.
error
[ફેરફાર કરો]{{#invoke:debug|error|message}}
This function is invoked from templates, and simply triggers a script error with a message. This is useful if you want to trigger a script error but don't have the time or knowledge to convert a template to Lua.
local export = {}
-- Convert a value to a string
function export.dump(value)
local t = type(value)
if t == "string" then
return '"' .. value .. '"'
elseif t == "table" then
local str_table = {}
for key, val in pairs(value) do
table.insert(str_table, "[" .. export.dump(key) .. "] = " .. export.dump(val))
end
return "{" .. table.concat(str_table, ", ") .. "}"
else
return tostring(value)
end
end
function export.track(key)
local frame = mw.getCurrentFrame()
pcall(frame.expandTemplate, frame, { title = 'tracking/' .. key })
end
-- Trigger a script error from a template
function export.error(frame)
error(frame.args[1] or "(કોઈ સંદેશ ઉલ્લેખિત નથી)")
end
return export