Zeta Components Manual :: Docs For Class ezcTemplateConfiguration
Template::ezcTemplateConfiguration
Class ezcTemplateConfiguration
Contains the common configuration options for template managers.
Whenever a template source or compiled code is accessed it will use the $templatePath and $compilePath respectively as the base path. The full path is generated by using the value of theses variables and then appending a slash (/) and the subpath, this means it is possible to have the templates in the root of the filesystem by setting an empty string or a string starting with a slash. The next example demonstrates how the templatePath and compilePath can be set:
- // accessing templates in /usr/share and compile them in /var/cache
- $conf->templatePath = "/usr/share/eztemplate";
- $conf->compilePath = "/var/cache/eztemplate";
Accessing templates from the applications directory is done with a single dot (.), these are also the default values.
- // uses current directory for accessing templates and compiling them
- $conf->templatePath = ".";
- $conf->compilePath = ".";
The $context property is by default assigned to an ezcTemplateXhtmlContext object.
Source for this file: /Template/src/configuration.php
Version: | //autogen// |
Properties
ezcTemplateCacheManager | read/write |
$cacheManager
The object to use for caching of compile templates. |
string | read/write |
$cachedTemplatesPath
Relative path from the compilePath. |
bool | read/write |
$checkModifiedTemplates
Set to true, to recompile outdated compiled templates. |
string | read/write |
$compilePath
Base path where the compiled templates are stored. |
string | read/write |
$compiledTemplatesPath
Relative path from the compilePath. |
ezcTemplateOutputContext | read/write |
$context
Contains the template context. |
array(ezcTemplateCustomBlockDefinition) | read/write |
$customBlock
The currently registered custom blocks. |
array(ezcTemplateCustomFunctionDefinition) | read/write |
$customFunctions
The currently registered custom functions. |
bool | read/write |
$disableCache
Disable caching for development purposes. |
bool | read/write |
$executeTemplate
False to only compile the template without executing it. |
ezcTemplateLocator | read/write |
$locator
Set the locator object to dynamically translate the template file. |
string | read/write |
$sourceCharset
Charset of the literals in the original template file. |
string | read/write |
$targetCharset
Desired charset of literals in the compiled. |
string | read/write |
$templatePath
Base path where the source templates are stored. |
bool | read/write |
$trimWhitespace
Whether the parser should strip whitespace from the templates. |
Method Summary
public static ezcTemplateConfiguration |
getInstance(
[ $name
= "default"] )
Returns the unique configuration instance named $name. |
public ezcTemplateConfiguration |
__construct(
[ $templatePath
= "."] , [ $compilePath
= "."] , [ $context
= null] )
Initialises the configuration with default template, compiled path, and context. |
public void |
addExtension(
$customClass
)
Adds custom tags or functions to the customBlock or customFunction property and indirectly adds the custom extension to the template language. |
Methods
getInstance
Returns the unique configuration instance named $name.
Note: You only need to specify the name if you need multiple configuration objects.
Parameters:
Name | Type | Description |
---|---|---|
$name |
string | Name of the configuration to use. |
__construct
Initialises the configuration with default template, compiled path, and context.
All requested templates are search from the defined $templatePath. Use an empty string to fetch templates from the root of the filesystem.
All compiled templates are placed in subfolders under the compiled templates. Use an empty string to compile templates at the root of the filesystem.
Parameters:
Name | Type | Description |
---|---|---|
$templatePath |
string | Path where the source templates are stored. |
$compilePath |
string | Path where the compiled templates should be stored. |
$context |
ezcTemplateOutputContext | Context to use. Default is the ezcTemplateXhtmlContext. |
addExtension
Adds custom tags or functions to the customBlock or customFunction property and indirectly adds the custom extension to the template language.
The parameter $customBlockClass expects a class that implements either the interface ezcTemplateCustomBlock, ezcTemplateCustomFunction, or both.
New custom blocks are added to the ezcTemplateConfiguration::customBlocks property while custom functions are added to the ezcTemplateConfiguration::customFunctions property.
Parameters:
Name | Type | Description |
---|---|---|
$customClass |
string |
Exceptions:
Type | Description |
---|---|
ezcBaseValueException |
if the $customClass parameter is not a string, or when the classname that it represents does not implement either the ezcTemplateCustomBlock or ezcTemplateCustomFunction interface. |