Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/iantresman/sandbox/titlesubscripts
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local properties = { "id", "interwiki", "namespace", "fragment", "nsText", "subjectNsText", "text", "prefixedText", "fullText", "rootText", "baseText", "subpageText", "canTalk", "exists", "fileExists", "isContentPage", "isExternal", "isLocal", "isRedirect", "isSpecialPage", "isSubpage", "isTalkPage", "contentModel", "basePageTitle", "rootPageTitle", "talkPageTitle", "subjectPageTitle" } local methods = { -- "isSubpageOf", -- This method is commented out to avoid errors - it expects a table as input, not a string. "inNamespace", "inNamespaces", "hasSubjectNamespace", "subPageTitle", "partialUrl", "fullUrl", "localUrl", "canonicalUrl", -- "getContent" -- Commenting this out as dumping the entire page content in the output is confusing. :) But try uncommenting it and see what happens. } local currentTitle = mw.title.getCurrentTitle() function p.main(frame) result = "" for _, property in ipairs(properties) do result = result .. "\n# " .. property .. ": " .. tostring(currentTitle[property]) end -- currentTitle[method](currentTitle) works because it emulates Lua's colon syntax. This syntax is often -- used in implementing Lua's version of object-oriented programming. Take a look at -- http://www.lua.org/pil/16.html for a good explanation. for _, method in ipairs(methods) do result = result .. "\n# " .. method .. ": " .. tostring(currentTitle[method](currentTitle, "Template")) -- "Template" is used to prevent errors when the namespace methods are called. end return result end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/iantresman/sandbox/titlesubscripts/doc
(
edit
)