Editing Module:TNT

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 38: Line 38:


-- Forward declaration of the local functions
-- Forward declaration of the local functions
local sanitizeDataset, loadData, link, formatMessage
local formatMessage, loadData, link


function p.msg(frame)
function p.msg(frame)
Line 87: Line 87:


function p.doc(frame)
function p.doc(frame)
local dataset = 'Templatedata/' .. sanitizeDataset(frame.args[1])
return frame:extensionTag(
return frame:extensionTag('templatedata', p.getTemplateData(dataset)) ..
'templatedata',
  formatMessage(i18nDataset, 'edit_doc', {link(dataset)})
p.getTemplateData(mw.text.trim(frame.args[1]))
) .. formatMessage(i18nDataset, 'edit_doc', {link(dataset)})
end
end


function p.getTemplateData(dataset)
function p.getTemplateData(page)
dataset = 'Templatedata/' .. mw.text.trim(page)
-- 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 133: Line 135:


-- Local functions
-- Local functions
sanitizeDataset = function(dataset)
if not dataset then
return nil
end
dataset = mw.text.trim(dataset)
if dataset == '' then
return nil
elseif string.sub(dataset,-4) ~= '.tab' then
return dataset .. '.tab'
else
return dataset
end
end


loadData = function(dataset, lang)
loadData = function(dataset, lang)
dataset = sanitizeDataset(dataset)
if not dataset or dataset == '' then
if not dataset then
error(formatMessage(i18nDataset, 'error_no_dataset', {}))
error(formatMessage(i18nDataset, 'error_no_dataset', {}))
end
if string.sub(dataset,-4) ~= '.tab' then
dataset = dataset .. '.tab'
end
end


Please note that all contributions to Meta Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Meta Wiki:Copyrights for details). Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page: