Public Member Functions | |
Templum ($templatePath, $varsUniversal=array(), $locale=NULL) | |
Create a new Templum instance. | |
setVar ($varName, $varValue) | |
Set a universal variable which will available in each template created with this Templum instance. | |
setAutoEscape ($escape=True) | |
Turn the auto escape on or off. If on, all content rendered using {{ and }} will automatically be escaped with htmlspecialchars(). | |
setLocale ($locale) | |
Set the locale for templates. | |
template ($path, $varsGlobal=array(), $autoEscape=NULL) | |
Retrieve a template by from disk (caching it in memory for the duration of the Templum instance lifetime) or from cache. | |
Static Public Member Functions | |
static | templateFromString ($contents, $autoEscape=Null) |
Create a TemplumTemplate from a string. |
This is the main Templum class. It takes care of retrieval, caching and compiling of (translated) templates.
Templum::Templum | ( | $ | templatePath, | |
$ | varsUniversal = array() , |
|||
$ | locale = NULL | |||
) |
Create a new Templum instance.
$templatePath | (string) The full or relative path to the template directory. | |
$varsUniversal | (array) An array of key/value pairs that will be exported to every template retrieved using this template engine instance. | |
$locale | (string) The locale for the templates to retrieve. If a file with the suffix noted in $locale is available, it will be returned instead of the default .tpl file. |
TemplumError | if the $templatePath can't be found or isn't a directory. |
Templum::setVar | ( | $ | varName, | |
$ | varValue | |||
) |
Set a universal variable which will available in each template created with this Templum instance.
$varName | (string) The name of the variable. This will become available in the template as $VARNAME. | |
$varValue | (mixed) The value of the variable. |
Templum::setAutoEscape | ( | $ | escape = True |
) |
Turn the auto escape on or off. If on, all content rendered using {{ and }} will automatically be escaped with htmlspecialchars().
$escape | (boolean) True of False. If True, auto escaping is turned on (this is the default). If False, it is turned off for templates retrieved with this Templum engine. |
Templum::setLocale | ( | $ | locale | ) |
Set the locale for templates.
$locale | (string) The locale for the templates to retrieve. If a file with the suffix noted in $locale is available, it will be returned instead of the default .tpl file. |
Templum::template | ( | $ | path, | |
$ | varsGlobal = array() , |
|||
$ | autoEscape = NULL | |||
) |
Retrieve a template by from disk (caching it in memory for the duration of the Templum instance lifetime) or from cache.
$path | (string) TemplumTemplate path, without the .tpl extension, relative to the templatePath. | |
$varsGlobal | (array) Array of key/value pairs that will be exported to the returned template and all templates included by that template. | |
$autoEscape | (boolean) Whether to auto escape {{ and }} output with htmlspecialchars() |
TemplumError | if the template couldn't be read. |
static Templum::templateFromString | ( | $ | contents, | |
$ | autoEscape = Null | |||
) | [static] |
Create a TemplumTemplate from a string.
Create a TemplumTemplate instance using $contents as the template contents. This severely limited what you can do with the TemplumTemplate. There will be no including from the template, no translations, no caching, etc.
$contents | (string) The template contents. | |
$autoEscape | (boolean) Whether to auto escape {{ and }} output with htmlspecialchars() |