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 fromDeval\Renderer::inject
- Returns:
evaluated and rendered template as a string
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 plain_text_processor
Defines how plain text is processed (most useful for whitespace control), see Whitespace control for details.
- property undefined_variable_fallback
Defines how undefined variables are handled, see Undefined variable behavior for details.
- property version
PHP compatibility option, see PHP compatibility for details.