Module:PageInfo

-- Get the prefix, namespace, and name of the page where a transcluded lua invocation (parent frame) occurs. This is typically not a template name. local p = {} function p.PageInfo(frame) -- Implements local args = getArgs(frame, {		trim = false,		removeBlanks = false		}) local nameonly = false local nsonly = false local prefixonly = false if args["nameonly"] then nameonly = true end if args["nsonly"] then nsonly = true end if args["prefixonly"] then prefixonly = true end return p._thisPageInfo(args, onlyname, onlyns, onlyprefix) end

function p._thisPageInfo(frame) local thisPageTitle = mw.title.getCurrentTitle local pagePrefix = thisPageTitle.nsText local pageNamespace = thisPageTitle.namespace local pageName = thisPageTitle.text if onlyname then return pageName elseif onlyns then return pageNamespace elseif onlyprefix then return pagePrefix else return pagePrefix, pageNamespace, pageName end end

return p -->