Module:Namespace other
Appearance
![]() | This module depends on the following other modules: |
Implements
- {{main other}}
- {{page other}}
- {{category other}}
- {{template other}}
- {{module other}}
- {{talk other}}
- {{file other}}
- {{page index other}}
require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
function p._namespace_other(args)
local namespace = string.lower(args.demospace or mw.title.getCurrentTitle().nsText)
local target = string.lower(args.target or 'main')
if yesno(args['include-talk']) then
namespace = string.gsub(namespace, '[%s_]*talk', '')
end
local special_targets = {
['talk'] = function (ns)
return mw.title.new(mw.title.getCurrentTitle().rootText, ns).isTalkPage
end,
['main'] = function (ns)
return ns == '' or ns == 'main'
end
}
if namespace == target or (special_targets[target] and special_targets[target](namespace)) then
return args[1]
else
return args[2]
end
end
function p.namespace_other(frame)
return p._namespace_other(getArgs(frame))
end
local function _page_index_other(args)
local page_entry = args['page index'] or args['page'] or args[1]
local index_entry = args['page index'] or args['index'] or args[2]
local other_entry = args['other'] or args[3]
local namespace = string.lower(args.demospace or mw.title.getCurrentTitle().nsText)
namespace = string.gsub(namespace, '[%s_]*talk', '')
return (namespace == 'page' and page_entry) or (namespace == 'index' and index_entry) or other_entry
end
function p.page_index_other(frame)
return _page_index_other(getArgs(frame))
end
return p