Module:Transclusion count: Difference between revisions
Created page with "local p = {} function p.fetch(frame) local template = nil local return_value = nil -- Use demo parameter if it exists, otherwise use current template name local namespace = mw.title.getCurrentTitle().namespace if frame.args["demo"] and frame.args["demo"] ~= "" then template = mw.ustring.gsub(frame.args["demo"],"^[Tt]emplate:","") elseif namespace == 10 then -- Template namespace template = mw.title.getCurrentTitle().text elseif namespace == 828 then -- Modul..." |
Steven Buber (talk | contribs) m 1 revision imported |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
local return_value = nil | local return_value = nil | ||
-- Use demo parameter if it exists, | -- Use demo parameter if it exists, otherswise use current template name | ||
local namespace = mw.title.getCurrentTitle().namespace | 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 = | template = frame.args["demo"] | ||
elseif namespace == 10 then -- Template namespace | elseif namespace == 10 then -- Template namespace | ||
template = mw.title.getCurrentTitle().text | template = mw.title.getCurrentTitle().text | ||
Line 20: | Line 20: | ||
if namespace == 10 or namespace == 828 then | if namespace == 10 or namespace == 828 then | ||
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 status, data = pcall(function () | local status, data = pcall(function () | ||
return(mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other"))) | return(mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other"))) | ||
end) | end) | ||
if status then | if status then |