TemplateFile class

A template file that will be loaded and executed as PHP and its output returned.

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the TemplateFile class also inherits all the methods and properties of: WireData and Wire.

Show class?     Show args?       Only hookable?    

Common

NameReturnSummary 
TemplateFile::clearAll()
int

Clear out all pending output buffers

 
TemplateFile::get(string $key)
mixed

Get a set property from the template file, typically to check if a template has access to a given variable

 
TemplateFile::getArray()
array

Get an array of all variables accessible (locally scoped) to the PHP template file

 
TemplateFile::getRenderStack()
array

Get the current render stack

 
TemplateFile::halt()
$this

This method can be called by any template file to stop further render inclusions


Can also be used as property: TemplateFile::halt
 
TemplateFile::render()
string array

Render the template: execute it and return its output

TemplateFile::set(string $key, mixed $value)
this WireData

Set a property

 
TemplateFile::setAppendFilename(string $filename)
bool

Set a file to append to the template file at render time

 
TemplateFile::setChdir($chdir)
None

Set the directory to temporarily change to during rendering

 
TemplateFile::setFilename(string $filename)
bool

Sets the template file name, replacing whatever was set in the constructor

 
TemplateFile::setPrependFilename(string $filename)
bool

Set a file to prepend to the template file at render time

 
TemplateFile::setThrowExceptions(bool $throwExceptions)
None

Call this with boolean false to disable exceptions when file doesn’t exist

 
TemplateFile::setTrim(bool $trim)
None

Set whether rendered output should have leading/trailing whitespace trimmed

 

For hooks

These methods are only useful for hooking and should not be called directly.

Properties

NameReturnSummary 
TemplateFile::appendFilename array Optional file name(s) used for append. 
TemplateFile::currentFilename string Current file being rendered (whether primary, prepend, append). 
TemplateFile::filename string Primary file to render. 
TemplateFile::prependFilename array Optional file name(s) used for prepend. 
TemplateFile::trim bool Whether or not leading/trailing whitespace is trimmed from output 3.0.154+. 

Additional methods and properties

In addition to the methods and properties above, TemplateFile also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.252