Twig

Symfony Twig Concat String

Concatenating a string using Twig is pretty simple, if you know what you’re doing. In my first instance in Twig string concatenation, I wanted to dynamically load some assets based on the route parameters. With my solution, I ended doing something like this to load a stylesheet, for instance. <link rel=”stylesheet” type=”text/css” media=”all” href=”{{ asset(‘bundles/hack3r3dradio/css/’ Symfony Twig Concat String

Symfony 2: Enable Twig Extensions

The other day I was dicking around with some code and I felt like I needed to truncate a string. Fortunately I was working with Symfony, which uses Twig templates, which is definitely my preferred templating system in 2014. But by default Symfony’s Twig extensions, which give you stuff like a truncate filter, is not Symfony 2: Enable Twig Extensions