Jarvis Jarvis - 8 months ago 84
Twig Question

How to add class if single tag?

I have 4

, which are showed or not.

{% if li == 1 %}{% endif %}

How to add class if only one (single)
is showed?


You could achieve this slightly differently by applying the style only when the element is the single child of it's parent (only one is rendered)

ul li:only-child {
property: value;

link to w3schools article here