Difference between revisions of "Module:TNT"
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( | 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 | local json = mw.text.jsonEncode({ | ||
params=params, | params=params, | ||
paramOrder=paramOrder, | paramOrder=paramOrder, | ||
description=data.description | description=data.description | ||
} | }) | ||
json = string.gsub(json,'"zzz123":"",?', "") | |||
return | return json | ||
end | end | ||