PHP code example of reun / twig-utilities
1. Go to this page and download the library: Download reun/twig-utilities 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/ */
reun / twig-utilities example snippets
use Reun\TwigUtilities\Filters\Htmlpurify;
use Reun\TwigUtilities\Functions\CopyrightYear;
use Twig\Extension\AbstractExtension;
class MyExtension extends AbstractExtension
{
public function getFilters(): array
{
return [
Htmlpurify::getFilter(),
];
}
public function getFunctions(): array
{
return [
CopyrightYear::getFunction(),
]
}
}
// Add extension to Twig.
$twig->addExtension(new MyExtension());
use DI\Container;
use Twig\RuntimeLoader\ContainerRuntimeLoader;
$twig->addRuntimeLoader(new ContainerRuntimeLoader(new Container()));