Given a filename, render it as a ProcessWire template file
This is a shortcut to using the TemplateFile class.
File is assumed relative to /site/templates/
(or a directory within there) unless you specify a full path.
If you specify a full path, it will accept files in or below any of the following:
- /site/templates/
- /site/modules/
- /wire/modules/
Note this function returns the output to you, so that you can send the output wherever you want (delayed output).
For direct output, use the $files->include()
function instead.
Usage
// basic usage
$string = $files->render(string $filename);
// usage with all arguments
$string = $files->render(string $filename, array $vars = [], array $options = []);
Arguments
Name | Type(s) | Description |
---|---|---|
filename | string | Assumed relative to /site/templates/ unless you provide a full path name with the filename. If you provide a path, it must resolve somewhere in site/templates/, site/modules/ or wire/modules/. |
vars (optional) | array | Optional associative array of variables to send to template file. Please note that all template files automatically receive all API variables already (you don't have to provide them). |
options (optional) | array | Associative array of options to modify behavior:
|
Return value
string
bool
Rendered template file or boolean false on fatal error (and throwExceptions disabled)
Exceptions
Method can throw exceptions on error:
WireException
- if template file doesn't exist
See Also
API reference based on ProcessWire core version 3.0.236