{% %} twig syntax is only parsed in text area handler when a {{ }} token is present

Created on 10 February 2016, almost 9 years ago
Updated 30 May 2023, over 1 year ago

Problem/Motivation

When adding a custom text area field to a view with twig conditions ({% if condition %}) or twig flow control ({% for X in Y %}), it's not getting processed.

Steps to reproduce

  1. Create a view, display page
  2. Add a global unfiltered text field to the view's header
  3. Check use replacement tokens from the first row
  4. Add content with a Twig condition between {% %}
  5. Go to the view page and you'll see your twig code within the HTML

For example, assuming you've added your "Content type" field as one of the fields in your view, this Twig will not be executed and will instead just render the code as plain text:

{% if type matches '/Page/' %}
  <p>Twig Test</p>
{% endif %}

However, if we also output a field using {{ field_name }} somewhere within the code, then it will execute the Twig code:

{% if type matches '/Page/' %}
  <p>Twig Test: {{ type }}</p>
{% endif %}

Proposed resolution

Twig code contained in a view custom text area field should be executed regardless of whether that code renders a variable using {{ }}

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Views 

Last updated about 17 hours ago

Created by

🇦🇷Argentina yioPa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024