How to embed double quotes in Twig interpolation?

Twig
I am trying to replace sprintf(' href="%s%s"', ..., ...) from a PHP file into its Twig alternative. I'd like to use Twig's interpolation feature but, ...
10 months ago

How to replace string with variable in Twig

Twig
{% image '@AppBundle/Resources/public/images/florida.png'%} <img src="{{ asset_url }}" alt="Example" height="200" width="200"/> {% endimage ...
10 months ago

Twig Compare a parameter passed to a template inside the template

Twig
In Twig I successfully render a template and pass to it the following array with values: $params = array( 'value1' => '...
10 months ago

How do you get the current url in Twig?

Twig
Inside a twig template I will check if url is: http://example.com/search?keyword=test {% set pageTitle = query %} query is test else {% set page...
10 months ago

How to delete white spaces of a text in twig?

Twig
I'm using the twig template engine while using symfony2. I'm trying to find a way to delete the white spaces from a text. For example, I play shall ...
10 months ago

cannot load Twig template (Symfony 2.8.8)

Twig
So I have the folder structure below: According to the Symfony manual (click here), I should be able to load my Twig template but Symfony cannot fi...
10 months ago

Get length of array with condition on attribute

Twig
I'd like if is it possibel to get length of array with condition on attribute without create another query in the controller. public function pageAct...
10 months ago

Symfony2 - Hyperlink to an exterior url retrieved from database using TWIG

Twig
i'm using symfony 2.0.19, and i'm trying to create a hyperlink to an external URL, this URL is retrieved from database, i tried doing this <td>...
10 months ago

Change Wordpress Timber Template locations

Twig
I need to overwrite the page template locations for Woocommerce using timber Wordpress. All page Templates are stored in the theme root folder and i ...
10 months ago

Prevent quotes from being converted to HTML entities in twig ternary operator

Twig
The following does not convert the quotes to HTML entities {% for row in files %} <tr data-id="{{ row.id }}"><td>{{ row.name }}</td&...
10 months ago

Multidimensional Array in Twig

Twig
I am using Twig with PHP. I have a multidimensional array setup like this: Array ( [Special] => Array ( [277] => Array ...
10 months ago

symfony2: how to check if form is new?

Twig
I want to check if a form is new in my template, something like $form->isNew() in symfony 1.4, but i did not find a solution. Currently, i'm using th...
10 months ago

Print second level menu in Drupal 8

Twig
Drupal 8 markup changed quite a lot from Drupal 7 using the Twig Engine. We are developing a site with it. We want to print the second level menu link...
10 months ago

Twig: How to round up?

Twig
I have a division in twig. Sometimes, the result can be with decimals and i need to have always a rounded up result. Ex. 7 / 2 = 3.5 I would like...
10 months ago

Setting a Quiz System

Twig
I'm developing a MCQs based Quiz system where my goal is to assist teacher in adding a new Question and Choices for that question on the same page. Ac...
10 months ago

Generate the HTML template equivalent of a twig file?

Twig
I'd like to know if it's possible to have {filename}.html generated for every {filename}.html.twig? I know one solution is to copy and paste the sourc...
10 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...
10 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...
10 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...
10 months ago

What is the correct way to concatenate and trim in TWIG

Twig
I'm new to TWIG. I can do this in PHP, but I'm looking for the right way to do it in the template using TWIG. Controller code: public function inde...
10 months ago