Essence\Utility\Template::_compileFunction PHP Method

_compileFunction() protected static method

Returns a function used to replace variables by values.
See also: compile()
protected static _compileFunction ( array $variables, callable | null $filter ) : Closure
$variables array Variables.
$filter callable | null Filter function.
return Closure Function.
    protected static function _compileFunction(array $variables, $filter)
    {
        return function ($matches) use($variables, $filter) {
            $name = $matches['variable'];
            $value = isset($variables[$name]) ? $variables[$name] : '';
            return $filter ? call_user_func($filter, $value) : $value;
        };
    }