8,290
edits
(Created page with "local p = {} -- Helper function to test for truthy and falsy values local function truthy(value) if not value or value == '' or value == 0 or value == '0' or value == 'false...") |
m (remove references to Module:TNT, which we don't have) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 98: | Line 98: | ||
-- Helper function to convert template arguments into an array of options fit for get() | -- Helper function to convert template arguments into an array of options fit for get() | ||
local function parseArgs(frame) | local function parseArgs(frame) | ||
local process_args = require('Module:ProcessArgs') | |||
local args = process_args.merge(true) | |||
return args | return args | ||
end | end | ||
Line 107: | Line 106: | ||
-- Throws a Lua error or returns an empty string if error reporting is disabled | -- Throws a Lua error or returns an empty string if error reporting is disabled | ||
local function throwError(key, value) | local function throwError(key, value) | ||
local TNT = require('Module:TNT') | -- local TNT = require('Module:TNT') | ||
local ok, message = pcall(TNT.format, 'I18n/Module:Transcluder.tab', 'error-' .. key, value) | -- local ok, message = pcall(TNT.format, 'I18n/Module:Transcluder.tab', 'error-' .. key, value) | ||
if not ok then message = key end | -- if not ok then message = key end | ||
local message = 'error-' .. key | |||
if value then | |||
message = message .. ': ' .. value | |||
end | |||
error(message, 2) | error(message, 2) | ||
end | end | ||
Line 116: | Line 119: | ||
-- Returns a wiki friendly error or an empty string if error reporting is disabled | -- Returns a wiki friendly error or an empty string if error reporting is disabled | ||
local function getError(key, value) | local function getError(key, value) | ||
local TNT = require('Module:TNT') | -- local TNT = require('Module:TNT') | ||
local ok, message = pcall(TNT.format, 'I18n/Module:Transcluder.tab', 'error-' .. key, value) | -- local ok, message = pcall(TNT.format, 'I18n/Module:Transcluder.tab', 'error-' .. key, value) | ||
if not ok then message = key end | -- if not ok then message = key end | ||
local message = 'error-' .. key | |||
if value then | |||
message = message .. ': ' .. value | |||
end | |||
message = mw.html.create('div'):addClass('error'):wikitext(message) | message = mw.html.create('div'):addClass('error'):wikitext(message) | ||
return message | return message |