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()
intClear out all pending output buffers 
TemplateFile::get(string $key)
mixedGet a set property from the template file, typically to check if a template has access to a given variable 
TemplateFile::getArray()
arrayGet an array of all variables accessible (locally scoped) to the PHP template file 
TemplateFile::getRenderStack()
arrayGet the current render stack 
TemplateFile::halt()
$thisThis method can be called by any template file to stop further render inclusions
Can also be used as property: TemplateFile::halt
 
TemplateFile::render()
stringRender the template: execute it and return its output
TemplateFile::set(string $key, mixed $value)
this WireDataSet a property 
TemplateFile::setAppendFilename(string $filename)
boolSet a file to append to the template file at render time 
TemplateFile::setChdir($chdir)
NoneSet the directory to temporarily change to during rendering 
TemplateFile::setFilename(string $filename)
boolSets the template file name, replacing whatever was set in the constructor 
TemplateFile::setPrependFilename(string $filename)
boolSet a file to prepend to the template file at render time 
TemplateFile::setThrowExceptions(bool $throwExceptions)
NoneCall this with boolean false to disable exceptions when file doesn’t exist 
TemplateFile::setTrim(bool $trim)
NoneSet 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

NameReturnSummaryDefault
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.251