API reference¶
Renderer¶
Common interface¶
-
class
Deval\
Renderer
¶ Main Deval class used to compile and render template after injecting values to it.
-
inject
($constants)¶ Inject values into template. Only serializable values can be injected as Deval may need to store them in intermediate document. If you need to inject functions, give them a name (do not use anonymous functions) and inject this name into Deval.
Parameters: - $constants (array) – key-value array to inject into template, each value will be injected with name taken from its associated key
-
render
($variables = array())¶ Evaluate and render template after optionally specifying runtime values. Any value, serializable or not, can be passed to this method. If you need to inject method, pass an array with class name (for static methods) or instance (for instance methods) as first item and method name as second item.
Parameters: - $variables (array) – key-value array to inject into template, similar to the one from
Deval\Renderer::inject
Returns: evaluated and rendered template as a string
- $variables (array) – key-value array to inject into template, similar to the one from
-
Implementations¶
-
class
Deval\
CacheRenderer
¶ Implementation for production usage, using an intermediate cache for pre-evaluated template code.
-
_construct
($path, $directory, $setup = null)¶ Create a new
Deval\CacheRenderer
instance.Parameters: - $path (string) – path to input template file
- $directory (string) – directory where cached files will be stored
- $setup (Deval\Setup) – renderer configuration
-
-
class
Deval\
FileRenderer
¶ Implementation for development usage, perform rendering from template file on each request with no caching.
-
_construct
($path, $setup = null)¶ Create a new
Deval\FileRenderer
instance.Parameters: - $path (string) – path to input template file
- $setup (Deval\Setup) – renderer configuration
-
-
class
Deval\
StringRenderer
¶ Implementation for development usage, perform rendering from template string on each request with no caching.
-
_construct
($source, $setup = null)¶ Create a new
Deval\StringRenderer
instance.Parameters: - $source (string) – template source code
- $setup (Deval\Setup) – renderer configuration
-
Builtin¶
-
class
Deval\
Builtin
¶ Utility class providing different “flavors” of builtin functions.
-
deval
()¶ Returns Deval favor builtin functions, see Deval flavor functions for details.
Returns: functions array
-
php
()¶ Returns PHP favor builtin functions, see PHP flavor functions for details.
Returns: functions array
-
Setup¶
-
class
Deval\
Setup
¶ Configuration class for
Deval\Renderer
.-
property
style
¶ Whitespace handling option, see Whitespace control for details.
-
property
version
¶ PHP compatibility option, see PHP compatibility for details.
-
property