Jump to content

Module:Transclusion count: Difference between revisions

m
1 revision imported
(add a truthy check too)
m (1 revision imported)
(2 intermediate revisions by 2 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