Difference between revisions of "Module:Transclusion count/sandbox"
Jump to navigation
Jump to search
blackwiki>Ahecht (Allow passing a default value to be used if the lookup fails.) |
blackwiki>Ahecht (data from query uses underscores) |
||
| Line 5: | Line 5: | ||
local index = mw.ustring.upper(mw.ustring.sub(template,1,1)) | 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")) | 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 | + | return data[mw.ustring.gsub(template, " ", "_")] or frame.args[1] or nil |
end | end | ||
return p | return p | ||
Revision as of 04:42, 10 August 2019
Documentation for this module may be created at Module:Transclusion count/sandbox/doc
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[mw.ustring.gsub(template, " ", "_")] or frame.args[1] or nil
end
return p