Blog: Twig

Pedro Iturriaga's picture
Pedro Iturriaga

Drupal twig, different ways to translate.

After searching, once again, how to solve a translation in the Drupal 8 template system, it occurred to me that it would be good to always have a notes on hand with the different ways in which we can do a twig translation. Let us begin.

The best known and simple, we apply the filter | t to the text string:

    {{ 'Hello World!'|t }}

We can also use the | trans filter, but this is more useful when we use it as a block:

    {% trans %}Hello World!{% endtrans %}

It is clear that this form uses...

Pedro Iturriaga's picture
Pedro Iturriaga

Twig: HTML links and variables.

One of the main new features of Drupal 8 is the Twig template engine because its workflow is very different from what we use to do in Drupal 7.

As a first impression when we consult the Twig documentation it looks like everything you need to start working is there -or almost anything-. But it will be during the day to day where you will find to problems that need solving.

In this post the issue is about adding a link in Twig using the link($text, $...

Subscribe to RSS - Twig