1. Go to this page and download the library: Download phpixie/template library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class HTML implements \PHPixie\Template\Extensions\Extension
{
public function name()
{
return 'html';
}
//Methods we would like to expose
public function methods()
{
return array('escape', 'output');
}
//Also we can assign aliases to some methods, meaning that they will also
//be assigned to a specified local variable
//In this case it allows us to use $_($name) instead of $this->escape($name)
public function aliases()
{
return array(
'_' => 'escape'
);
}
public function escape($string)
{
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
public function output($string)
{
echo $this->escape($string);
}
}
class HamlFormat implements \PHPixie\Template\Formats\Format
{
protected $mtHaml;
public function __construct()
{
$this->mtHaml = new \MtHaml\Environment('php');
}
public function handledExtensions()
{
return array('haml'); // register which file extension we handle
}
public function compile($file)
{
$contents = file_get_contents($file);
return $this->mtHaml->compileString($contents, $file);
}
}