Twig Templating
Twig is Drupal's templating language, coming from Symfony.
https://twig.symfony.com/
https://www.drupal.org/docs/develop/theming...
Twig is Drupal's templating language, coming from Symfony.
https://twig.symfony.com/
https://www.drupal.org/docs/develop/theming...
Since twig templates are cached, you have to clear the cache each time you make a change in order to see it. For developing...
I added a new comment type, called Question. Unfortunately, it's hardcoded with "Add new comment" and looks exactly the same as...
I have a view that lists required courses on a degree detail page for a school. These courses link back to a listing page, with...
Examples for modifying arrays in twig.
Drupal twig filters documentation.
Drupal twig function documentation.
To change multiple parts of an Attributes object in twig, merge it with an object keyed with updated attributes.
Use the output to create a new attributes object and overwrite the attributes variable.
You may want to transform a value in a twig template.
You can do that by checking a condition on the value in an if, and provide values in the then/else.
{% set newvalue = value == 'asdf' ? '123': '456' %}
If you have different inputs and outputs, you can create a switch like this.
{% set title_color = {green: 'text-green-3', yellow: 'text-yellow-2', blue: 'text-grey-2'}[color] %}
This defines an object, then uses the input value to retrieve the mapped result.