MediaWiki REL1_40
|
Public Member Functions | |
__construct ( $templateDir=null, ?BagOStuff $cache=null) | |
enableRecursivePartials ( $enable) | |
Enable/disable the use of recursive partials. | |
processTemplate ( $templateName, $args, array $scopes=[]) | |
Returns HTML for a given template by calling the template function with the given args. | |
Protected Member Functions | |
compile ( $templateName) | |
Compile the Mustache template into PHP code using LightnCandy. | |
getTemplate ( $templateName) | |
Returns a given template function if found, otherwise throws an exception. | |
getTemplateFilename ( $templateName) | |
Constructs the location of the source Mustache template. | |
Protected Attributes | |
int | $compileFlags |
Compilation flags passed to LightnCandy. | |
callable[] | $renderers |
Array of cached rendering functions. | |
string | $templateDir |
The path to the Mustache templates. | |
Definition at line 35 of file TemplateParser.php.
MediaWiki\Html\TemplateParser::__construct | ( | $templateDir = null, | |
?BagOStuff | $cache = null ) |
string | null | $templateDir | |
BagOStuff | null | $cache | Read-write cache |
Definition at line 64 of file TemplateParser.php.
References MediaWiki\Html\TemplateParser\$templateDir, CACHE_ANYTHING, and ObjectCache\getLocalServerInstance().
|
protected |
Compile the Mustache template into PHP code using LightnCandy.
The compilation step generates both PHP code and metadata, which is also returned in the result. An example result looks as follows:
The files
entry is a list of the files read during the compilation of the template. Each entry is the fully-qualified filename, i.e. it includes path information.
The filesHash
entry can be used to determine whether the template has changed since it was last compiled without compiling the template again. Currently, the filesHash
entry is generated with FileContentsHasher::getFileContentsHash.
string | $templateName | The name of the template |
\Exception Thrown by LightnCandy if it could not compile the Mustache code
RuntimeException | If LightnCandy could not compile the Mustache code but did not throw an exception. This exception is indicative of a bug in LightnCandy |
Definition at line 215 of file TemplateParser.php.
References FileContentsHasher\getFileContentsHash(), and MediaWiki\Html\TemplateParser\getTemplateFilename().
Referenced by MediaWiki\Html\TemplateParser\getTemplate().
MediaWiki\Html\TemplateParser::enableRecursivePartials | ( | $enable | ) |
Enable/disable the use of recursive partials.
bool | $enable |
Definition at line 77 of file TemplateParser.php.
|
protected |
Returns a given template function if found, otherwise throws an exception.
string | $templateName | The name of the template (without file suffix) |
RuntimeException | When the template file cannot be found |
RuntimeException | When the compiled template isn't callable. This is indicative of a bug in LightnCandy |
Definition at line 110 of file TemplateParser.php.
References MediaWiki\Html\TemplateParser\$compileFlags, MediaWiki\Html\TemplateParser\compile(), FileContentsHasher\getFileContentsHash(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\MediaWikiServices\hasInstance(), and MediaWiki\MainConfigNames\SecretKey.
Referenced by MediaWiki\Html\TemplateParser\processTemplate().
|
protected |
Constructs the location of the source Mustache template.
string | $templateName | The name of the template |
UnexpectedValueException | If $templateName attempts upwards directory traversal |
Definition at line 91 of file TemplateParser.php.
Referenced by MediaWiki\Html\TemplateParser\compile().
MediaWiki\Html\TemplateParser::processTemplate | ( | $templateName, | |
$args, | |||
array | $scopes = [] ) |
Returns HTML for a given template by calling the template function with the given args.
string | $templateName | The name of the template |
-taint | $templateName | exec_misc |
mixed | $args | |
-taint | $args | none |
array | $scopes | |
-taint | $scopes | none |
Definition at line 294 of file TemplateParser.php.
References MediaWiki\Html\TemplateParser\getTemplate().
|
protected |
Compilation flags passed to LightnCandy.
Definition at line 58 of file TemplateParser.php.
Referenced by MediaWiki\Html\TemplateParser\getTemplate().
|
protected |
Array of cached rendering functions.
Definition at line 53 of file TemplateParser.php.
|
protected |
The path to the Mustache templates.
Definition at line 48 of file TemplateParser.php.
Referenced by MediaWiki\Html\TemplateParser\__construct().