PHP code example of svengerlach / vanillajs-template
1. Go to this page and download the library: Download svengerlach/vanillajs-template 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/ */
svengerlach / vanillajs-template example snippets
$compiler = new \Svengerlach\VanillaJSTemplate\Compiler();
$template = '<h1>Hello, <%= foo %>!</h1>';
$templateCompiled = $compiler->compile($template);
santiate twig loader
$loader = new \Twig_Loader_Filesystem([__DIR__]);
// instantiate twig
$twig = new \Twig_Environment($loader);
// instantiate compiler
$compiler = new \Svengerlach\VanillaJSTemplate\Compiler();
// instantiate twig extension
$extension = new \Svengerlach\VanillaJSTemplate\TwigExtension($compiler);
// add extension to twig
$twig->addExtension($extension);
// see twig template below
echo $twig->render('twigextension.html.twig');