Module:TNT: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(Updating from mw) |
(copying from mediawiki. Please allow my bot to do it instead - see mw:WP:TNT. Thanks!) |
||
Line 39: | Line 39: | ||
-- Forward declaration of the local functions |
-- Forward declaration of the local functions |
||
local |
local sanitizeDataset, loadData, link, formatMessage |
||
function p.msg(frame) |
function p.msg(frame) |
||
Line 75: | Line 75: | ||
function p.doc(frame) |
function p.doc(frame) |
||
⚫ | |||
return frame:extensionTag( |
|||
return frame:extensionTag('templatedata', p.getTemplateData(dataset)) .. |
|||
⚫ | |||
p.getTemplateData(mw.text.trim(frame.args[1])) |
|||
⚫ | |||
end |
end |
||
function p.getTemplateData( |
function p.getTemplateData(dataset) |
||
⚫ | |||
-- TODO: add '_' parameter once lua starts reindexing properly for "all" languages |
-- TODO: add '_' parameter once lua starts reindexing properly for "all" languages |
||
local data = loadData(dataset) |
local data = loadData(dataset) |
||
Line 124: | Line 122: | ||
-- Local functions |
-- Local functions |
||
sanitizeDataset = function(dataset) |
|||
if not dataset then |
|||
return nil |
|||
⚫ | |||
dataset = mw.text.trim(dataset) |
|||
⚫ | |||
return nil |
|||
elseif string.sub(dataset,-4) ~= '.tab' then |
|||
⚫ | |||
else |
|||
return dataset |
|||
end |
|||
end |
|||
loadData = function(dataset, lang) |
loadData = function(dataset, lang) |
||
dataset = sanitizeDataset(dataset) |
|||
if not dataset then |
|||
error(formatMessage(i18nDataset, 'error_no_dataset', {})) |
error(formatMessage(i18nDataset, 'error_no_dataset', {})) |
||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||