Toggle menu
24K
663
183
158.1K
HausaDictionary.com | Hausa English Translations
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:debug

From HausaDictionary.com | Hausa English Translations

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

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 "(no message specified)")
end

return export