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 bool Set to true to halt during render, or use method $this->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.236

Latest news

  • ProcessWire Weekly #515
    In the 515th issue of ProcessWire Weekly we’ll check out the latest core updates, new modules, and more. Read on!
    Weekly.pw / 23 March 2024
  • Invoices Site Profile
    The new invoices site profile is a free invoicing application developed in ProcessWire. It enables you to create invoices, record payments to them, email invoices to clients, print invoices, and more. This post covers all the details.
    Blog / 15 March 2024
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH