Module:TNT: Difference between revisions

Jump to navigation Jump to search
metawikimedia>YurikBot
m Copying 4 changes by Yurik: "docs link, add language param, better description, more docs changes" from mw:Module:TNT. See docs.
metawikimedia>DiBabelYurikBot
m Copying 5 changes by Yurik: "fix templatedata doc having just the positional parameters, better description, more docs changes, fixed doc link, Trim parameter whitespaces" from mw:Module:TNT. See docs.
Line 72: Line 72:


function p.doc(frame)
function p.doc(frame)
dataset = 'Templatedata/' .. normalizeDataset(frame.args[1])
return frame:extensionTag(
'templatedata',
p.getTemplateData(frame.args[1])
) .. tntMessage('edit_doc', {link(dataset)})
end
 
function p.getTemplateData(page)
dataset = 'Templatedata/' .. normalizeDataset(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 98: Line 105:
     end
     end
     end
     end
   
    -- Work around json encoding treating {"1":{...}} as an [{...}]
    params['zzz123']=''
local templateData = {
local json = mw.text.jsonEncode({
params=params,
params=params,
paramOrder=paramOrder,
paramOrder=paramOrder,
description=data.description
description=data.description
}
})
 
templateData = mw.text.jsonEncode(templateData)
json = string.gsub(json,'"zzz123":"",?', "")


return frame:extensionTag('templatedata', templateData) .. tntMessage('edit_doc', {link(dataset)})
return json
end
end