Module:NAMESPACEID
This Lua module is used in Template:Editnotice load/core. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid major disruption, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them. |
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 returns the namespace ID of a page. It must be used via a template, typically the {{NAMESPACEID}} template.
-- This module implements {{NAMESPACEID}}.
local p = {}
function p.main(frame)
local ns = frame:getParent().args[1] or mw.title.getCurrentTitle().namespace
local nsTable = mw.site.namespaces[ns]
if nsTable then
return nsTable.id
else
return '<strong class="error">Invalid namespace in ' ..
'{{[[Template:NAMESPACEID|NAMESPACEID]]}}</strong>'
end
end
return p