Skip to content

Instantly share code, notes, and snippets.

@bobdenotter
Created December 11, 2012 17:29
Show Gist options
  • Save bobdenotter/4260478 to your computer and use it in GitHub Desktop.
Save bobdenotter/4260478 to your computer and use it in GitHub Desktop.
Bare bones example of broken {{ render() }}
{
"require": {
"silex/silex": "1.0.*@dev",
"twig/twig": ">=1.8,<2.0-dev",
"symfony/twig-bridge": "2.1.*"
},
"minimum-stability": "dev"
}
<?php
require_once __DIR__.'/vendor/autoload.php';
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__.'/views'
));
$app->match('/', function () use ($app) {
return $app['twig']->render('index.twig');
});
$app->match('/sub', function () use ($app) {
// This next line is the culprit..
$app['twig']->addGlobal('foo', 'bar');
return "This is the sub";
});
$app->run();
<h1>Silex / Twig render demo</h1>
{{ render('/sub') }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment