PHP code example of deniaz / terrific-twig

1. Go to this page and download the library: Download deniaz/terrific-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/ */

    

deniaz / terrific-twig example snippets


class TemplateInformationProvider implements TemplateInformationProviderInterface
{
    public function getPaths()
    {
      return []; // List of path where Terrific Components can be found, e.g. (/var/www/example.com/frontend/components)
    }
    
    public function getFileExtension()
    {
      $fileExtension = 'html.twig';
      return $fileExtension;
    }
}

class ContextProvider implements ContextProviderInterface
{
    public function compile(Twig_Compiler $compiler, Twig_Node $component, Twig_Node $dataVariant, $only) {
        // ...
    }
}

$loader = ...;
$chain = new Twig_Loader_Chain([$loader, new TerrificLoader(new TemplateInformationProvider)]);
$twig = new Twig_Environment($chain);

$twig = new Twig_Environment($chain);
$twig->addExtension(new TerrificExtension(new ContextProvider));