Quantcast
Viewing all articles
Browse latest Browse all 294989

Views tokens: id and class

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 294989

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>