mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ParserFunctions
synced 2024-11-28 02:00:23 +00:00
f53debae7d
Change-Id: I0c7719f17f74180a4c85f914888262f7e3b13111
29 lines
654 B
PHP
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() );
|
|
}
|
|
}
|
|
|
|
}
|