Via Composer
$ composer require shapecode/twig-collector-extension-bundle
Enable the bundle in your kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Shapecode\Bundle\TwigCollectorBundle\ShapecodeTwigCollectorBundle(),
);
}
collect stuff over all templates
{% collector stylesheets %}
<style>
.body {
margin-bottom: 10px;
}
</style>
{% endcollector %}
... and output it at a specific line
{% collection stylesheets %}