Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sample Twig setup and template
require __DIR__.'/../vendor/autoload.php';
$loader = new Twig_Loader_Filesystem(__DIR__.'/../templates');
$twig = new Twig_Environment($loader, array(
// Uncomment the line below to cache compiled templates
// 'cache' => __DIR__.'/../cache',
$name = filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING);
if (!$name) {
$name = "Mercury, Venus, Mars, Jupiter, Saturn, Uranus & Neptune.";
echo $twig->render('index.twig', array(
'name' => $name,
<!DOCTYPE html>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Twig test</title>
<h1>Hello world</h1>
<p>And hello {{ name }}</p>

This comment has been minimized.

Copy link

craigiswayne commented Nov 17, 2018

Helpful :) thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.