There is a issue if you are trying to use replacement patterns when creating custom css class for field, label or field and label wrapper html. If you put the replacement pattern as usual with the syntax

{{ pattern }}

the view is broken.

This is because the css classes get exploded by whitespace in line 381 of core/modules/views/src/Plugin/views/field/FieldPluginBase.php:
$classes = explode(' ', $this->options['element_wrapper_class']);
API ref: https://api.drupal.org/api/drupal/core!modules!views!src!Plugin!views!fi...

This separates the curly braces from the pattern, so that you have an array of three items "{{", "pattern" and "}}".

If you put the pattern without whitespace between the curly braces and the pattern element it will work as expected.

But if you just copy the pattern from the replacement pattern section it will not work. So I think this is what most of the users will do, so this should be working I suppose.

I am not sure how to fix it properly. Is this white space between the braces and the element really needed? It works without the whitespace also in the rewrite results section. So should the pattern templates be put without whitespace?

CommentFileSizeAuthor
cssclass_replacement.png112.25 KBstefan.korn
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stefan.korn’s picture

Issue summary: View changes
Manuel Garcia’s picture

Version: 8.0.0-beta10 » 8.0.x-dev

Confirming this is a problem right now on HEAD.

Further more, during my tests I got a white screen The website encountered an unexpected error. Please try again later., and the watchdog shows this PHP error:

Twig_Error_Syntax: Unexpected token "end of template" of value "" in "{# inline_template_start #}{{" at line 1 in Twig_ExpressionParser->parsePrimaryExpression() (line 190 of /var/www/drupal8/core/vendor/twig/twig/lib/Twig/ExpressionParser.php).

Manuel Garcia’s picture

We should fix this on:

  • FieldPluginBase::elementClasses
  • FieldPluginBase::elementLabelClasses
  • FieldPluginBase::elementWrapperClasses

The fix should be the same for all of these.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Lendude’s picture

Status: Active » Closed (duplicate)

#2543796: Using token views to rewrite css output causes Twig_Error_Syntax, "Unexpected token "end of template" of value " in Twig/ExpressionParser.php line 190 fixed this, so closing this as a duplicate (it was technically the other way around since this is the older issue)

Lendude’s picture

Issue tags: +Bug Smash Initiative

Tagging for Bug Smash