Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291711

Views tokens: id and class

$
0
0

What is the correct syntax for using a token for an id or class in views custom field? Since the new twig syntax {{ token }} vs [token], tokens are not parsing correctly when used as class or id. Is there a better way to do this?

None of these work correctly for token {{ title }} in a "Global: Custom text" field.

<div id="{{ title }}"><p>{{ title }}</p></div>

#using local variable#
{% set my_id = '{{ title }}' %}<div{{ attributes.setAttribute('id', 'my_id') }}>{{ my_id }}</div>

#using filter this does create a working id but the text is not clean token text.
<div id="{{ title|clean_id }}"><p>{{ title }}</p></div>

Thanks for any info!!


Viewing all articles
Browse latest Browse all 291711

Trending Articles