TemplateFile class

Located in file /wire/core/TemplateFile.php

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?        

Common

NameReturnSummary 
TemplateFile::appendFilename array Optional file name(s) used for append. 
TemplateFile::clearAll()
intClear out all pending output buffers 
TemplateFile::currentFilename string Current file being rendered (whether primary, prepend, append). 
TemplateFile::filename string Primary file to render. 
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::prependFilename array Optional file name(s) used for prepend. 
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)
(nothing)Set 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)
(nothing)Call this with boolean false to disable exceptions when file doesn’t exist 
TemplateFile::setTrim(bool $trim)
(nothing)Set whether rendered output should have leading/trailing whitespace trimmed 
TemplateFile::trim bool Whether or not leading/trailing whitespace is trimmed from output (3.0.154+). 

For hooks

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

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.244

Latest news

  • ProcessWire Weekly #558
    In the 558th issue of ProcessWire Weekly we'll check out the blog post that introduces ProcessWire 3.0.244, share some recent ProcessWire highlights, and more. Read on!
    Weekly.pw / 18 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

“Indeed, if ProcessWire can be considered as a CMS in its own right, it also offers all the advantages of a CMF (Content Management Framework). Unlike other solutions, the programmer is not forced to follow the proposed model and can integrate his/her ways of doing things.” —Guy Verville, Spiria Digital Inc.