bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

Conditional CSS Class on Element #1216

Closed AndrewMarkUK closed 3 years ago

AndrewMarkUK commented 3 years ago

Hi

This is more of a question that an issue. hope its OK for me to write it here.

I am wishing to include a conditional css within an element tag but wondering the best way to do this, for example say I have:

After a number of attempts of different methods (that did not work) I came up with this...BUT, I don't think it is ideal...

`

    <false>
        <div class="row row-cols-1 row-cols-md-3 g-3 mb-3 pt-3">
    </false>

`

We can see from true I am removing 'row-cols-md-3'

But a method from within the tag would perhaps be better?

Anyone done this?

ikkez commented 3 years ago

You can simplify this with a ternary condition:

<div class="row row-cols-1 {{ @Columns==8 ? '' : 'row-cols-md-3' }} g-3 mb-3 pt-3">
AndrewMarkUK commented 3 years ago

! the one things I did not try 👍

Thank you