PHP code example of jdwx / twig

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

    

jdwx / twig example snippets


    $env = TwigHelper::forDirectory( __DIR__ . '/templates' );

    $twig = new StaticTwigStream( $env, 'example', [ 'name' => 'Static' ] );
    echo $twig, "\n"; # "Hello, Static!"

    $map = new Map();
    $twig = new MapTwigStream( $env, 'example', $map );
    $map->put( 'name', 'Map' );
    echo $twig, "\n"; # "Hello, Map!"