PHPackages                             gloomy/twig-decorator-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. gloomy/twig-decorator-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

gloomy/twig-decorator-bundle
============================

Twig extension to make conditional layout and to inject variables in templates

0.1(12y ago)246MITPHP

Since Dec 11Pushed 12y agoCompare

[ Source](https://github.com/iamluc/GloomyTwigDecoratorBundle)[ Packagist](https://packagist.org/packages/gloomy/twig-decorator-bundle)[ Docs](https://github.com/iamluc/GloomyTwigDecoratorBundle)[ RSS](/packages/gloomy-twig-decorator-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

GloomyTwigDecoratorBundle
=========================

[](#gloomytwigdecoratorbundle)

ABOUT
-----

[](#about)

This bundle adds 2 tags in twig:

- {% grab %} which injects variables into the template
- {% decorate %} that you can use instead of the {% extends %} tag to determine which layout to use to extend your template, and inject custom variables to each layout.

[![Build Status](https://camo.githubusercontent.com/5e619b4dd12ae9af6a6d90689b7bab923720bee28f9e31f5a1b8e6764189c9f3/68747470733a2f2f6170692e7472617669732d63692e6f72672f69616d6c75632f476c6f6f6d79547769674465636f7261746f7242756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/iamluc/GloomyTwigDecoratorBundle) [![SensioLabsInsight](https://camo.githubusercontent.com/a7e4b47ed52b37c366e53b8e18916bd707b533cc3a1b7bdce3dc0601b5798c16/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f36626335363739662d623062302d343537662d386361392d6338316562666234373137322f6d696e692e706e67)](https://insight.sensiolabs.com/projects/6bc5679f-b0b0-457f-8ca9-c81ebfb47172) [![Total Downloads](https://camo.githubusercontent.com/74bf570ff3c0194aac2dd7e227f9be8dad944e411d2d3a02bff7b7042b33c962/68747470733a2f2f706f7365722e707567782e6f72672f676c6f6f6d792f747769672d6465636f7261746f722d62756e646c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/gloomy/twig-decorator-bundle)

USAGE
-----

[](#usage)

### {% grab %}

[](#-grab-)

```
{% grab 'my_grabber' %}
{# or #}
{% grab 'my_grabber' with {'var1': 'my_value'} %}
```

The bundle comes with 1 grabber:

- ControllerGrabber

    This grabber will be used only to inject variables inside the template from a controller.

    ```
    {% grab 'controller' with {
        '_controller': 'MyBundle:MyController:MyMethod',
        'my_own_var': 'cool !'}
    %}
    ```

    ```
