Essence\Utility\Template::compile PHP Method

compile() public static method

Compiles a template with variables.
public static compile ( string $template, array $variables, callable $filter = null ) : string
$template string Template.
$variables array Variables.
$filter callable Filter function.
return string Compiled template.
    public static function compile($template, array $variables, $filter = null)
    {
        return preg_replace_callback(self::variablePattern, self::_compileFunction($variables, $filter), $template);
    }

Usage Example

 /**
  *
  */
 public function testCompile()
 {
     $template = Template::compile(':foo {:bar}', ['foo' => 'foo', 'bar' => 'bar']);
     $this->assertEquals('foo bar', $template);
     $template = Template::compile(':html', ['html' => '<html>'], 'htmlspecialchars');
     $this->assertEquals('&lt;html&gt;', $template);
 }
All Usage Examples Of Essence\Utility\Template::compile