mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ParserFunctions
synced 2024-11-15 11:59:54 +00:00
04e4c1b300
Change-Id: I8f985ca83223f1a2fdb4365294701f3b1d9b019b
24 lines
578 B
PHP
24 lines
578 B
PHP
<?php
|
|
|
|
class Scribunto_LuaParserFunctionsLibrary 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 [ ExtParserFunctions::getExprParser()->doExpression( $expression ) ];
|
|
} catch ( ExprError $e ) {
|
|
throw new Scribunto_LuaError( $e->getMessage() );
|
|
}
|
|
}
|
|
|
|
}
|