PHP code example of namics / twig-nitro-library

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

    

namics / twig-nitro-library example snippets


class TemplateInformationProvider implements TemplateInformationProviderInterface
{
    public function getPaths() {
    /* List of path where Terrific Components can be found, e.g.
      @code
      [
        '/var/www/example.com/frontend/src/atoms',
        '/var/www/example.com/frontend/src/molecules',
        '/var/www/example.com/frontend/src/organisms'
      ]
      @endcode */
      return [];
    }
}

class ContextProvider implements ContextProviderInterface
{
    public function compile(\Twig\Compiler $compiler, \Twig\Node\Node $component, \Twig\Node\Node $dataVariant, $only) {
        // ...
    }
}

$loader = ...;
$chain = new \Twig\Loader\ChainLoader([$loader, new TerrificLoader(new TemplateInformationProvider)]);
$twig = new \Twig\Environment($chain);

$twig = new \Twig\Environment($chain);
$twig->addExtension(new TerrificExtension(new ContextProvider));