Difference between revisions of "Module:TNT"

174 bytes added ,  17:32, 25 April 2019
fix templatedata doc having just the positional parameters
>Yurik
(docs link)
>Yurik
(fix templatedata doc having just the positional parameters)
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


Anonymous user