# danog\MadelineProto\WebUI\TemplateEngine: Renders the native PHP templates of the web UI.

> 
A template name like `page` or `partials/field` is looked up as `page.phtml` or `partials/field.phtml`
in each of the configured directories, in order, and then in the builtin template directory: a custom
directory only needs to contain the templates it overrides.

Inside a template, `$this` is a {@see Template}, and the variables passed to the template are in scope.


[Back to index](../../../index.html)

> Author: Daniil Gentili <daniil@daniil.it>  
  

Renders the native PHP templates of the web UI.  


A template name like `page` or `partials/field` is looked up as `page.phtml` or `partials/field.phtml`
in each of the configured directories, in order, and then in the builtin template directory: a custom
directory only needs to contain the templates it overrides.

Inside a template, `$this` is a {@see Template}, and the variables passed to the template are in scope.



## Constants
* `danog\MadelineProto\WebUI\TemplateEngine::BUILTIN_DIRECTORY`: Directory of the builtin templates.


## Method list:
* [`__construct(list<string> $directories = [])`](#__construct)
* [`getDirectories(): list<string>`](#getDirectories)
* [`render(string $name, array<string, mixed> $data = []): string`](#render)
* [`exists(string $file): bool`](#exists)
* [`resolve(string $file): string`](#resolve)
* [`asset(string $file): string`](#asset)

## Methods:
### <a name="__construct"></a> `__construct(list<string> $directories = [])`




Parameters:

* `$directories`: `list<string>` Template directories, searched in order before the builtin one.  



### <a name="getDirectories"></a> `getDirectories(): list<string>`

Get the template directories, in lookup order.



### <a name="render"></a> `render(string $name, array<string, mixed> $data = []): string`

Render a template.


Parameters:

* `$name`: `string` Template name, without the .phtml extension  
* `$data`: `array<string, mixed>` Variables passed to the template  



### <a name="exists"></a> `exists(string $file): bool`

Check whether a template or asset exists.


Parameters:

* `$file`: `string` File name relative to the template directories, including the extension  



### <a name="resolve"></a> `resolve(string $file): string`

Get the path of a template or asset.


Parameters:

* `$file`: `string` File name relative to the template directories, including the extension  



### <a name="asset"></a> `asset(string $file): string`

Get the contents of an asset (stylesheet, script, image...).


Parameters:

* `$file`: `string` File name relative to the template directories, including the extension  



---
Generated by [danog/phpdoc](https://phpdoc.daniil.it)
