Created
December 21, 2012 11:45
-
-
Save mattattui/4352331 to your computer and use it in GitHub Desktop.
Sample Twig setup and template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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, | |
)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Twig test</title> | |
</head> | |
<body> | |
<h1>Hello world</h1> | |
<p>And hello {{ name }}</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Helpful :) thank you