Iterating over key-value arrays in Twig?

Twig
I'm (finally) switching my site from Drupal7 to Symfony3. I'm working on migrating my layout to .twig. I've got a question about loops and key-value...
4 months ago

Send associative array from HTML to JS

Twig
I need to send few values through html data attribute to JS. <div class="article" data-article="[{% for data in article %}{{ data }},{% e...
4 months ago

testing twig with phpunit

Twig
I want to implement some unit tests with Twig and PHPUnit(both installed with composer, with slim/views added). But when I try to test a template gene...
4 months ago

Twig extension: render template with variables

Twig
I have created a twig extension te render a view with some variables , but I have this error An exception has been thrown during the rendering of a t...
4 months ago

how to display a specified value from an multidimensional array in twig template

Twig
I tried to display the service name from the array service. But I did not get the all names. In twig template it only shows the last entered name. Any...
4 months ago

variables {% set %} in a skeleton file's 'block' don't get recognized , and can't be used when extnding the file?

Twig
I have a symfony3/twig skeleton template page1/skeleton.twig {# set default values #} {% block content %} {% set test = { sec...
4 months ago

How to config twig and Timber to translate full twig templates with {% trans %} tags

Twig
I've been trying to make Timber render and translate templates with {% trans %} tags. I created a .po tranlation file with poedit and Twig-Gettext-E...
5 months ago

Symfony2 - checking if file exists

Twig
I have a loop in Twig template, which returns multiple values. Most important - an ID of my entry. When I didn't use any framework nor template engine...
5 months ago

Using a Twig variable inside a Symfony translation in a template

Twig
It is getting late and I think my mind is shutting down...for the life of me I cannot work out how to change the translation key to work with the valu...
5 months ago

Twig embed block not working when its within a loop?

Twig
I need to place a twig template into my page and place another twig template inside it. In page.twig: {% embed "parent.twig" %} {% block somethin...
5 months ago

Get Template Directory Timber/Twig

Twig
I have a setup a simple twig template which is used to display a simple menu. I have images in here that are static and I would like use the template ...
5 months ago

Make a preg replace on string in twig

Twig
I'm trying to find ou a way to make this in twig but I can't find a solution.. preg_replace('/(\w+)([A-Z])/U', '\\1 \\2', ucfirst("thisIsAnExample"))...
3 months ago

How can I use the index from a Twig for loop in the name of an object property?

Twig
I'm trying to use the index of a for loop in the property names of an object. Is this possible? {% for i in 0..20 %} {% include 'template.twig' ...
3 months ago

Directly access a form field's value when overriding widget in a twig template

Twig
What I want to do is get variables stored in form view. {% form_theme edit_form _self %} {% block field_widget %} {% spaceless %} {% set type = type...
3 months ago

Find missing "empty" translation in Symfony project

Twig
While checking the logs of my Symfony 2.8 project I came across the following warnings: Translation not found. Context: { "id": "", "domain": "messa...
3 months ago

How to get at runtime the route name in Symfony2 when using the yaml routes description?

Twig
Here you can find my n-th question on Symfony2. I'm working with a pagination bundle that uses the route name provided in the routing.yml file. From ...
3 months ago

Making Twig filter to assign defaults unless otherwise specified

Twig
I'm trying to use twig as a template system for my website. I'm wanting to write something along the lines of... {{ title }} {% pageAuthor | Unknown ...
4 months ago

Symfony from styling time widgets

Twig
I am currently trying to style a form that is generated by symfony form builder. there is a bootstrap overlay on it but i want to move the time widg...
4 months ago

Accessing session from TWIG template

Twig
I've searched a lot on the net how to access the global $_SESSION array from TWIG template and found this: {{app.session.get('index')}}, but when I'm ...
5 months ago

Using php code in .twig file slim framework

Twig
I am using Slim Framework for the first time and also using twig for templatizing. I have a land.twig file the contents of that file are <form ac...
5 months ago