• Fabien Potencier's avatar
    [TwigExtension] added a way to use in-memory templates · 737d4f0f
    Fabien Potencier authored
    Usage:
    
    use Silex\Application;
    use Silex\Extension\TwigExtension;
    
    require_once __DIR__.'/silex.phar';
    
    $app = new Application();
    
    $templates = array(
        'hello' => 'Hello {{ name }}',
    );
    
    $app->register(new TwigExtension(), array(
        'twig.templates'  => $templates,
        'twig.class_path' => '/path/to//Twig/lib',
    ));
    
    $app->get('/{name}', function($name) use ($app) {
        return $app['twig']->render('hello', array('name' => $name));
    });
    
    $app->run();
    737d4f0f
TwigExtension.php 1.23 KB