2017 © Pedro Peláez
 

symfony-bundle twig-global-bundle

TcTwigGlobalBundle

image

tc/twig-global-bundle

TcTwigGlobalBundle

  • Thursday, May 7, 2015
  • by carlcraig
  • Repository
  • 3 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Tc Twig Global Bundle

Latest Stable Version, (*1)

SensioLabsInsight, (*2)

Provides some useful twig tags for global variables., (*3)

Installation

composer require tc/twig-global-bundle

Enable the bundle in your AppKernel.php, (*4)

$bundles = array(
    // ...

    new Tc\Bundle\TwigGlobal\TcTwigGlobalBundle(),

    // ...
);

Usage

Usage in Twig:, (*5)


{# set a global #} {% global title = 'My Title' %} {# get a global #} {% global title %} {# merging #} {% global title ~ ' | My Title Suffix' %} {# set defaults #} {% global title 'My Title' default %} {# this can be overwritten in a child template #} {% global title 'My Other Title' %} {# working with arrays #} {% global colors = ['red', 'green', 'blue'] %} {% global colors ~ 'purple' %} {# red, green, blue, purple #} {% global colors ~ ['red', 'blue', 'yellow'] unique %} {# red, green, blue, purple, yellow #} {# access globals outside of tag #} {{ _tc_global.get('title', 'some default value') }} {{ _tc_global.set('title', 'value', true /* default */) }} {{ _tc_global.merge('colors', 'purple', false /* default */, false /* unique */) }}

Usage in PHP via the tc.twig_global service:, (*6)

$container->get('tc.twig_global')->set('title', 'something');
$container->get('tc.twig_global')->get('title');
$container->get('tc.twig_global')->merge('colors', 'blue');
// etc

License

TcTwigGlobalBundle is licensed with the MIT license., (*7)

See LICENSE for more details., (*8)

The Versions

07/05 2015

dev-master

9999999-dev https://github.com/ThreeceeStudios/TcTwigGlobalBundle

TcTwigGlobalBundle

  Sources   Download

MIT

The Requires

 

by Carl Craig

twig tc twig-global-bundle twig global

07/05 2015

v1.0.0

1.0.0.0 https://github.com/ThreeceeStudios/TcTwigGlobalBundle

TcTwigGlobalBundle

  Sources   Download

MIT

The Requires

 

by Carl Craig

twig