mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-24 00:05:00 +00:00
Add a property "talkNsText" to mw.title objects
Bug: T180911 Change-Id: I847ac4b7587b98be06b25fe14765e9efdc7b774d
This commit is contained in:
parent
d75dd9fc0c
commit
e1bd4911bd
|
@ -64,7 +64,15 @@ local function makeTitleObject( data )
|
|||
data.isSpecialPage = data.namespace == mw.site.namespaces.Special.id
|
||||
data.isTalkPage = ns.isTalk
|
||||
data.subjectNsText = ns.subject.name
|
||||
data.canTalk = ns.talk ~= nil
|
||||
|
||||
if ns.talk ~= nil then
|
||||
data.canTalk = true
|
||||
if not data.isExternal then
|
||||
data.talkNsText = ns.talk.name
|
||||
end
|
||||
else
|
||||
data.canTalk = false
|
||||
end
|
||||
|
||||
data.prefixedText = data.text
|
||||
if data.nsText ~= '' then
|
||||
|
|
|
@ -266,6 +266,14 @@ local tests = {
|
|||
args = { 'subjectNsText' },
|
||||
expect = { '', 'Module', '', '', '', 'Module', 'Module' }
|
||||
},
|
||||
{ name = '.canTalk', func = prop_foreach,
|
||||
args = { 'canTalk' },
|
||||
expect = { true, true, true, true, true, true, true }
|
||||
},
|
||||
{ name = '.talkNsText', func = prop_foreach,
|
||||
args = { 'talkNsText' },
|
||||
expect = { 'Talk', 'Module talk', nil, 'Talk', 'Talk', 'Module talk', 'Module talk' }
|
||||
},
|
||||
{ name = '.fragment', func = prop_foreach,
|
||||
args = { 'fragment' },
|
||||
expect = { '', '', '', 'frag', '', ' frag frag', ' frag frag' }
|
||||
|
|
Loading…
Reference in a new issue