PHP code example of shapecode / twig-string-loader
1. Go to this page and download the library: Download shapecode/twig-string-loader 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/ */
shapecode / twig-string-loader example snippets
php
// index.php
//...
$loader1 = new \Twig\Loader\FilesystemLoader('/path/to/templates');
$loader2 = new \Shapecode\Twig\Loader\StringLoader();
$loader = new \Twig\Loader\ChainLoader([$loader1, $loader2]);
$twig = new \Twig\Environment($loader);
php
$twig->render('Hello {{ world }}', array(
'world' => 'World'
));