Module:Introspection utils: Difference between revisions

Ganaram inukshuk (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
add alternate implementation of get_and_preprocess_content that uses one fullpagename instead of separate namespace and pagename
Line 113: Line 113:
end
end
end
end
--[[
function p.get_and_preprocess_content(fullpagename)
if not fullpagename then return "" end
local title = mw.title.new(fullpagename)
local content = title and title:getContent() or ""
local lowercase_name = string.lower(fullpagename)
if string.match(lowercase_name, "^module:") then
return p.preprocess_code(content)
elseif string.match(lowercase_name, "^template:") then
return p.preprocess_wikitext(content)
else
return ""
end
end
]]--


-- -----------------------------------------------------------------------------
-- -----------------------------------------------------------------------------
Line 333: Line 351:
local pattern = "{{%s*#invoke:%s*" .. safe_mod_name .. "%s*|%s*" .. func_name
local pattern = "{{%s*#invoke:%s*" .. safe_mod_name .. "%s*|%s*" .. func_name
return string.find(wikitext, pattern) ~= nil
return string.find(wikitext, pattern) ~= nil
end
function p.tester()
local code = p.extract_and_preprocess_content("template", "MOS intervals")
return p.invocation_exists(code, "MOS intervals")
end
end


return p
return p