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 6: | Line 6: | ||
-- Use demo parameter if it exists, otherswise use current template name | -- Use demo parameter if it exists, otherswise use current template name | ||
if frame.args["demo"] and frame.args["demo"] ~= "" then | if frame.args["demo"] and frame.args["demo"] ~= "" then | ||
template = frame.args["demo"] | template = frame.args["demo"] | ||
elseif namespace == 10 then -- Template namespace | elseif mw.title.getCurrentTitle().namespace == 10 then -- Template namespace only | ||
template = mw.title.getCurrentTitle().text | template = mw.title.getCurrentTitle().text | ||
end | end | ||
-- If in template | -- If in template namespace, look up count in /data | ||
if template ~= nil | if template ~= nil and mw.title.new(template, "Template").namespace == 10 then | ||
template = mw.ustring.gsub(template, "/doc$", "") -- strip /doc from 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")) | |||
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")]) | |||
end | end | ||