Andrew Fletcher published: 18 September 2023 (updated) 19 September 2023 1 minute read
Twig error
Twig\Error\SyntaxError: Unknown "filter" tag. in Twig\Parser->subparse() (line 6 of themes/custom/{theme}/templates/views/views-view-field--products--field_product_type.html.twig).
Line 6 of the views-view-field--products--field_product_type.html.twig file is
{% filter upper|escape('html') %}
The actual Twig file code
{% filter upper|escape('html') %}
{{ view.field.field_product_type.original_value -}}
{% endfilter %}
In Drupal 10, this is producing the error noted above - Unknown "filter" tag
Solution
Change the code as follows
{{ view.field.field_product_type.original_value|upper|escape('html') -}}
Related articles
Andrew Fletcher
•
11 Feb 2025
Webpack build process and theme automation improvements
The Drupal theme configuration has undergone recent changes made to the Webpack configuration, SCSS and JavaScript handling, and automation of updates to the orw.libraries.yml file in the custom Drupal theme. These changes are designed to improve the build process, enhance maintainability, and...
Andrew Fletcher
•
30 Jan 2025
Enhancing accessibility in Drupal by adding aria-label to input fields using Twig
Accessibility is a fundamental aspect that ensures experiences are inclusive for all users, including those relying on assistive technologies. One crucial accessibility feature is the use of `aria-label` attributes to provide contextual information for form inputs. In Drupal, we can dynamically set...
Andrew Fletcher
•
22 Jan 2025
Removing a missing module in Drupal
Occasionally, a Drupal site may display a warning about a module being "Missing or invalid." This issue occurs when a module is marked as installed in the configuration but is no longer present in the file system. A common example is the `fakeobjects` module, which is associated with CKEditor 4 and...