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?
Comment | File | Size | Author |
---|---|---|---|
cssclass_replacement.png | 112.25 KB | stefan.korn |
Comments
Comment #1
stefan.kornComment #2
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedConfirming 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)
.Comment #3
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedWe should fix this on:
The fix should be the same for all of these.
Comment #12
Lendude#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)
Comment #13
LendudeTagging for Bug Smash