Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Guild of Archivists
Search
Editing
Module:Ns has subpages
From Guild of Archivists
Namespaces
Module
Discussion
More
More
Page actions
Read
Edit source
History
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!
-- This module implements [[Template:Ns has subpages]]. -- While the template is fairly simple, this information is made available to -- Lua directly, so using a module means that we don't have to update the -- template as new namespaces are added. local p = {} function p._main(ns, frame) -- Get the current namespace if we were not passed one. if not ns then ns = mw.title.getCurrentTitle().namespace end -- Look up the namespace table from mw.site.namespaces. This should work -- for a majority of cases. local nsTable = mw.site.namespaces[ns] -- Try using string matching to get the namespace from page names. -- Do a quick and dirty bad title check to try and make sure we do the same -- thing as {{NAMESPACE}} in most cases. if not nsTable and type(ns) == 'string' and not ns:find('[<>|%[%]{}]') then local nsStripped = ns:gsub('^[_%s]*:', '') nsStripped = nsStripped:gsub(':.*$', '') nsTable = mw.site.namespaces[nsStripped] end -- If we still have no match then try the {{NAMESPACE}} parser function, -- which should catch the remainder of cases. Don't use a mw.title object, -- as this would increment the expensive function count for each new page -- tested. if not nsTable then frame = frame or mw.getCurrentFrame() local nsProcessed = frame:callParserFunction('NAMESPACE', ns) nsTable = nsProcessed and mw.site.namespaces[nsProcessed] end return nsTable and nsTable.hasSubpages end function p.main(frame) local ns = frame:getParent().args[1] if ns then ns = ns:match('^%s*(.-)%s*$') -- trim whitespace ns = tonumber(ns) or ns end local hasSubpages = p._main(ns, frame) return hasSubpages and 'yes' or '' end return p
Summary:
Please note that all contributions to Guild of Archivists 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
GoArch:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Ns has subpages/doc
(
edit
)
Navigation
Navigation
Main Page
Random page
Categories
All pages
Recent changes
Resources
D'ni dictionary
Reference material
Utilities
Community
Forums
Jalak Game Directory
Projects
Apocrypha
Unexplored Branches
All projects
Contribute
Stubs
Wanted
Cleanup
Dead ends
Image requested
Help
Help
Guide
Policies
Wiki tools
Wiki tools
Special pages
Page values
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs