Editing Module:Transclusion count
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 2: | Line 2: | ||
function p.fetch(frame) | function p.fetch(frame) | ||
local template = | local template = mw.ustring.gsub(mw.title.getCurrentTitle().text, "/doc$", "") | ||
if frame.args["demo"] and frame.args["demo"] ~= "" then | if frame.args["demo"] and frame.args["demo"] ~= "" then | ||
template = frame.args["demo"] | template = mw.ustring.gsub(frame.args["demo"], "/doc$", "") | ||
end | end | ||
local index = mw.ustring.upper(mw.ustring.sub(template,1,1)) | |||
local data = mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other")) | |||
local return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")]) | |||
-- If database value doesn't exist, use value passed to template | -- If database value doesn't exist, use value passed to template | ||
if return_value = | if return_value == nil then | ||
local arg1=mw.ustring.match(frame.args[1], '[%d,]+') | local arg1=mw.ustring.match(frame.args[1], '[%d,]+') | ||
return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R')) | |||
end | end | ||