mediawiki-extensions-Parser.../includes/LuaLibrary.php
Max Semenik f53debae7d Namespace this extension
Change-Id: I0c7719f17f74180a4c85f914888262f7e3b13111
2019-04-03 19:20:14 -07:00

29 lines
654 B
PHP

<?php
namespace MediaWiki\Extensions\ParserFunctions;
use Scribunto_LuaError;
use Scribunto_LuaLibraryBase;
class LuaLibrary extends Scribunto_LuaLibraryBase {
public function register() {
$lib = [
'expr' => [ $this, 'expr' ],
];
return $this->getEngine()->registerInterface(
__DIR__ . '/mw.ext.ParserFunctions.lua', $lib, []
);
}
public function expr( $expression = null ) {
$this->checkType( 'mw.ext.ParserFunctions.expr', 1, $expression, 'string' );
try {
return [ ParserFunctions::getExprParser()->doExpression( $expression ) ];
} catch ( ExprError $e ) {
throw new Scribunto_LuaError( $e->getMessage() );
}
}
}