Jump to content

Module:Transclusion count: Difference between revisions

m
1 revision imported
m (1 revision imported)
m (1 revision imported)
(3 intermediate revisions by 3 users not shown)
Line 21: Line 21:
template =  mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end
template =  mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end
local index = mw.ustring.sub(mw.title.new(template).text,1,1)
local index = mw.ustring.sub(mw.title.new(template).text,1,1)
local data = mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other"))
local status, data = pcall(function ()
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")])
return(mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other")))  
end)
if status then
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")])
end
end
end
end
end
Line 29: Line 33:
if return_value == nil and frame.args[1] ~= nil then
if return_value == nil and frame.args[1] ~= 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'))
if arg1 and arg1 ~= '' then
return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R'))
end
end
end