Basic setup to get you started with Twig. For setting up:
- Copy templates to your template directory
- Modify
base_project.html.twig
to match your general project template - You may want to alter all project specific variables (starting with
{{ app.
) to match your project variables - Add more templates for special views
For more information see Twig Documentation. Twig is used by Symfony2, Silex and Drupal 8+.
- Copy files from
/TwigBroiler/Ressources/views
to/app/Ressources/views/
- Create new bundle in
/src/TwigBroilerBundle
viaphp app/console generate:bundle
- Copy all files to
/src/TwigBroilerBundle
- Create
/src/TwigFiltersBundle/Ressources/config/services.yml
- Copy files from
/TwigBroiler/Ressources/views
to/app/views/
- Copy files from
/TwigBroiler
to/src/TwigBroiler
- Copy these lines to
/app/app.php
$loader->add('TwigBroiler', realpath(__DIR__.'/../src'));
$app['asset_path'] = '';
$app['locale'] = 'de';
$app['config']['frontend'] = array(
'title' => '…',
'description' => '…',
);
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__.'/views',
));
$app['twig']->addExtension(new \TwigBroiler\Twig\CsvExtension());
$app['twig']->addExtension(new \TwigBroiler\Twig\HelperExtension());
$app['twig']->addExtension(new \TwigBroiler\Twig\HtmlExtension());
$app['twig']->addExtension(new \TwigBroiler\Twig\JsExtension());
$app['twig']->addExtension(new \TwigBroiler\Twig\SocialMediaExtension());
$app->before(function () use ($app) {
$app['twig']->addGlobal('base', $app['twig']->loadTemplate('base.html.twig'));
$app['twig']->addGlobal('base_project', $app['twig']->loadTemplate('base_project.html.twig'));
});
Version: 0.9 (2014-07-25)
Author: Frank Boës
Copyright & license: See LICENSE.txt