Jump to content

Module:Transclusion count/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ahecht (talk | contribs) at 04:37, 10 August 2019 (Allow passing a default value to be used if the lookup fails.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

function p.main(frame)
	local template = frame.args[2] or mw.title.getCurrentTitle().text
	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 data[template] or frame.args[1] or nil
end

return p