1. Go to this page and download the library: Download tigr/twig-preprocessor 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/ */
tigr / twig-preprocessor example snippets
$realLoader = Twig_Loader_Filesystem('/path/to/templates');
$loader = Twig_Loader_Preprocessor(
$realLoader,
function($twigSource) {
// do something with $twigSource
return $twigSource;
}
);
$twig = new Twig_Environment($loader);
$loader = new Twig_Loader_Preprocessor(
$realLoader,
function ($template) {
static $regExp;
// the RE isn't perfect, it won't match structures having curly braces within,
// but it's okay for me.
if (!isset($regExp)) {
$regExp = str_replace(
['_', '{', '}'],
['[\t ]*', '\{', '\}'],
'/^_({([#%])[^}]*[^-](?2)}|{%_block_\w*_%}{%_endblock_%})$/m'
);
}
return preg_replace($regExp, '$1', $template);
}
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.