mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-27 17:50:06 +00:00
Add title.content
alias for Title::getContent()
No other access in the Title class contains a `get` prefix, so this makes the title methods consistent. Bug: T373047 Change-Id: I4a3a7498462b7b3b6143dc61f529e526ccb112e2
This commit is contained in:
parent
9c4fc5a95c
commit
13b7e5ab31
|
@ -168,6 +168,7 @@ local function makeTitleObject( data )
|
||||||
end
|
end
|
||||||
|
|
||||||
function data:getContent()
|
function data:getContent()
|
||||||
|
-- deprecated: should use `title.content` instead
|
||||||
checkSelf( self, 'getContent' )
|
checkSelf( self, 'getContent' )
|
||||||
local content = php.getContent( self.fullText )
|
local content = php.getContent( self.fullText )
|
||||||
data.getContent = function ( self )
|
data.getContent = function ( self )
|
||||||
|
@ -301,6 +302,12 @@ local function makeTitleObject( data )
|
||||||
end
|
end
|
||||||
return data.redirectTarget
|
return data.redirectTarget
|
||||||
end
|
end
|
||||||
|
if k == 'content' then
|
||||||
|
if data.content == nil then
|
||||||
|
data.content = php.getContent( data.prefixedText ) or false
|
||||||
|
end
|
||||||
|
return data.content
|
||||||
|
end
|
||||||
if k == 'categories' then
|
if k == 'categories' then
|
||||||
if data.categories == nil then
|
if data.categories == nil then
|
||||||
data.categories = php.getCategories( data.prefixedText )
|
data.categories = php.getCategories( data.prefixedText )
|
||||||
|
|
|
@ -75,6 +75,11 @@ local function test_getContent()
|
||||||
mw.title.new( 'ScribuntoTestNonExistingPage' ):getContent()
|
mw.title.new( 'ScribuntoTestNonExistingPage' ):getContent()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function test_content()
|
||||||
|
return mw.title.new( 'ScribuntoTestPage' ).content,
|
||||||
|
mw.title.new( 'ScribuntoTestNonExistingPage' ).content
|
||||||
|
end
|
||||||
|
|
||||||
local function test_redirectTarget()
|
local function test_redirectTarget()
|
||||||
local targets = {}
|
local targets = {}
|
||||||
local titles = {
|
local titles = {
|
||||||
|
@ -412,6 +417,13 @@ local tests = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ name = '.content', func = test_content,
|
||||||
|
expect = {
|
||||||
|
'{{int:mainpage}}<includeonly>...</includeonly><noinclude>...</noinclude>',
|
||||||
|
false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
{ name = '.redirectTarget', func = test_redirectTarget, type = 'ToString',
|
{ name = '.redirectTarget', func = test_redirectTarget, type = 'ToString',
|
||||||
expect = { 'ScribuntoTestTarget', false, false }
|
expect = { 'ScribuntoTestTarget', false, false }
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue