1. Go to this page and download the library: Download wanze/template-engine-twig 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/ */
wanze / template-engine-twig example snippets
wire()->addHookAfter('TemplateEngineTwig::initTwig', function (HookEvent $event) {
/** @var \Twig\Environment $twig */
$twig = $event->arguments('twig');
$twig->addFunction(new \Twig\TwigFunction('processwire', function () {
return 'ProcessWire rocks!';
}));
});
// ... and then use it anywhere in a Twig template:
{{ processwire() }}