မဝ်ဂျူ:Ns has subpages
ထာမ်ပလိက်တဏအ်ဝွံမရပ်စပ်သုၚ်စောဲမတော်ခယျၜိုတ် မုက်လိက် ၊ သီုအရာ ≈14520% ဆေၚ်စပ်ကဵုသီုဖအိုတ် မုက်လိက်ဟေၚ်. To avoid large-scale disruption and unnecessary server load, any changes to it should first be testedပ္ဍဲမဆေၚ်စပ်ကဵုထာမ်ပလိက် /sandbox ဝါ /testcases မုက်လိက်တန်ဍောတ်၊ ဝါ ပ္ဍဲမုက်လိက်တန်ဍောတ်ညးလွပ်ဒြပ်ဇကု။ The tested changes can then be added to this page in a single edit. သ္ပဂုန်တုဲစၚ်ခြၚ်ချပ်ဗ္စာရဏာသဳကၠဳပရေၚ်ဂွံပြံၚ်လှာဲလ္တူဆေၚ်စပ်ကဵုရပ်စပ်စကာညးလွပ် ဓရီုကျာညိကၠာ။ |
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module finds whether a given namespace can have subpages.
Usage
ပလေဝ်ဒါန်From wikitext
ပလေဝ်ဒါန်From wikitext this module must be used via the {{ns has subpages}} template. Please see the template page for documentation.
From Lua
ပလေဝ်ဒါန်Usually Lua modules should use mw.site.namespaces[namespace].hasSubpages
rather than this module. But if you have a good reason, it can be accessed like this:
Load the module:
local mNsHasSubpages = require('Module:Ns has subpages')
The subpage information can be found with the ._main function:
mNsHasSubpages._main(ns, frame)
- ns is the namespace name, number, or a page name. It defaults to the current namespace.
- frame is a frame object with which we can call frame:callParserFunction if necessary. This is optional, and intended for internal use.
-- 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