MediaWiki REL1_34
LuaLibrary.php
Go to the documentation of this file.
1<?php
2
4
7
9 public function register() {
10 $lib = [
11 'expr' => [ $this, 'expr' ],
12 ];
13
14 return $this->getEngine()->registerInterface(
15 __DIR__ . '/mw.ext.ParserFunctions.lua', $lib, []
16 );
17 }
18
19 public function expr( $expression = null ) {
20 $this->checkType( 'mw.ext.ParserFunctions.expr', 1, $expression, 'string' );
21 try {
22 $exprParser = new ExprParser();
23 return [ $exprParser->doExpression( $expression ) ];
24 } catch ( ExprError $e ) {
25 throw new Scribunto_LuaError( $e->getMessage() );
26 }
27 }
28
29}
This class provides some basic services that Lua libraries will probably need.
checkType( $name, $argIdx, $arg, $expectType)
Check the type of a variable.
getEngine()
Get the engine.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
Definition ExprError.php:19