Environment
class Environment
Properties
protected | $extensionInitialized | ||
protected | $loadedTemplates | ||
$loader | |||
protected | $cache | ||
protected CompilerInterface | $compiler | ||
static protected array | $globalsCache | ||
protected | $templateClassPrefix | ||
protected | $extensions | ||
protected bool | $debug | ||
protected mixed | $templateClass | ||
protected | $charset |
Methods
Sets the default template charset.
Gets the default template charset.
Gets the current cache implementation.
Sets the current cache implementation.
No description
No description
No description
Renders a template.
Loads a template internal representation.
Creates a template from source.
Returns true if the template is still fresh.
Registers a Global.
Gets the registered Globals.
Merges a context with the defined globals.
No description
No description
Details
at line 63
__construct(TemplateLoader $loader, array $options = [])
Constructor.
Available options:
- debug: When set to true, it automatically set "auto_reload" to true as well (default to false).
- charset: The charset used by the templates (default to UTF-8).
- templateClass: The base template class to use for generated templates.
- cache: An absolute path where to store the compiled templates, or false to disable compilation cache.
at line 84
setLoader(TemplateLoader $loader)
No description
at line 93
Loader
getLoader()
Gets the Loader instance.
at line 107
setCharset(string $charset)
Sets the default template charset.
at line 116
string
getCharset()
Gets the default template charset.
at line 126
FileSystem
getCache()
Gets the current cache implementation.
at line 136
setCache($cache)
Sets the current cache implementation.
at line 141
getCompiler()
No description
at line 151
setCompiler(CompilerInterface $compiler)
No description
at line 156
getTemplateClass()
No description
at line 171
string
render(string $name, array $context = [])
Renders a template.
at line 197
Template
loadTemplate(string $name, string $path)
Loads a template internal representation.
at line 225
Template
createTemplate(string $template)
Creates a template from source.
at line 252
bool
isTemplateFresh(string $name, int $time)
Returns true if the template is still fresh.
at line 266
addGlobal(string $name, mixed $value)
Registers a Global.
New globals can be added before compiling or rendering a template; but after, you can only update existing globals.
at line 276
array
getGlobals()
Gets the registered Globals.
at line 288
array
mergeGlobals(array $context)
Merges a context with the defined globals.
at line 301
addExtension(AbstractExtension $extension)
No description
at line 312
initExtensions()
No description
at line 324
protected
initExtension(AbstractExtension $extension)
No description
at line 331
protected
addDirective($name, $callback)
No description