Created
April 21, 2011 00:05
-
-
Save igorw/933384 to your computer and use it in GitHub Desktop.
Silex app with global Twig layout
This file contains 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__.'/silex.phar'; | |
$app = new Silex\Application(); | |
$app->register(new Silex\Extension\TwigExtension(), array( | |
'twig.path' => __DIR__.'/views', | |
'twig.class_path' => __DIR__.'/vendor/twig/lib', | |
)); | |
$app->before(function () use ($app) { | |
$app['twig']->addGlobal('layout', $app['twig']->loadTemplate('layout.twig')); | |
}); | |
$app->match('/', function () use ($app) { | |
return $app['twig']->render('index.twig'); | |
}); | |
$app->run(); |
This file contains 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
{% extends layout %} | |
{% block content %} | |
<h1>Ponies</h1> | |
<p> | |
are awesome. | |
</p> | |
{% endblock %} |
This file contains 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> | |
<title>Nice title here</title> | |
</head> | |
<body> | |
{% block content %}{% endblock %} | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi There! Did you ever figure out what was going on here?