Editing Module:Transclusion count

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. Read the Privacy Policy to learn what information we collect about you and how we use it.

If you log in or create an account, your edits will be attributed to your username, along with other benefits.

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
local namespace = mw.title.getCurrentTitle().namespace
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
elseif namespace == 828 then -- Module namespace
template = (mw.site.namespaces[828].name .. ":" .. mw.title.getCurrentTitle().text)
end
end


-- If in template or module namespace, look up count in /data
-- If in template namespace, look up count in /data
if template ~= nil then
if template ~= nil and mw.title.new(template, "Template").namespace == 10 then
namespace = mw.title.new(template, "Template").namespace
template =  mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end
if namespace == 10 or namespace == 828 then
local index = mw.ustring.upper(mw.ustring.sub(template,1,1))
template =  mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end
local data = mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other"))
local index = mw.ustring.sub(mw.title.new(template).text,1,1)
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")])
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
end
Line 29: Line 23:
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,]+')
if arg1 and arg1 ~= '' then
return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R'))
return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R'))
end
end
end
Please note that all contributions to Nonbinary Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Nonbinary Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page: