diff --git a/engines/LuaCommon/LuaCommon.php b/engines/LuaCommon/LuaCommon.php index 0514c997..f79bd161 100644 --- a/engines/LuaCommon/LuaCommon.php +++ b/engines/LuaCommon/LuaCommon.php @@ -81,6 +81,7 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase { 'preprocess', 'incrementExpensiveFunctionCount', 'isSubsting', + 'getFrameTitle', ); $lib = array(); @@ -401,6 +402,14 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase { return array( $newFrameId ); } + /** + * Handler for getTitle() + */ + function getFrameTitle( $frameId ) { + $frame = $this->getFrameById( $frameId ); + return array( $frame->getTitle()->getPrefixedText() ); + } + /** * Handler for getExpandedArgument() */ diff --git a/engines/LuaCommon/lualib/mw.lua b/engines/LuaCommon/lualib/mw.lua index 8d342ef3..f53da201 100644 --- a/engines/LuaCommon/lualib/mw.lua +++ b/engines/LuaCommon/lualib/mw.lua @@ -536,6 +536,11 @@ local function newFrame( frameId, ... ) ) end + function frame:getTitle() + checkSelf( self, 'getTitle' ) + return php.getFrameTitle( frameId ) + end + -- For backwards compat function frame:argumentPairs() checkSelf( self, 'argumentPairs' ) diff --git a/tests/engines/LuaCommon/luaParserTests.txt b/tests/engines/LuaCommon/luaParserTests.txt index f271cf86..6468cf34 100644 --- a/tests/engines/LuaCommon/luaParserTests.txt +++ b/tests/engines/LuaCommon/luaParserTests.txt @@ -137,6 +137,10 @@ function p.isSubsting( frame ) return tostring( mw.isSubsting() ) end +function p.getFrameTitle( frame ) + return frame:getTitle() +end + return p !! endarticle @@ -385,3 +389,12 @@ Scribunto: isSubsting during normal parse
false
!! end + +!! test +Scribunto: frame:getTitle +!! input +{{#invoke:test|getFrameTitle}} +!! result +Module:Test +
+!! end