2

Is there a way to find out if a css class exists in a specific tag through twig?

For example:

<body class="new-class">

Then I'm able to do a conditional statement in twig based if new-class exists. Is this possible?

1 Answer 1

4

You could use hasClass to find the CSS class in a specific tag

eg. {% if body.attributes.hasClass('new-class') %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.