Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline if statement in grails

Tags:

grails

groovy

gsp

Is there a way in Grails to do conditionals inline on an HTML attribute, for example:

<div class="${if(sec.isLoggedIn()) loggedInClass}">

I'm trying to add a class to certain elements if the user is logged in.

like image 766
TripWired Avatar asked May 13 '26 21:05

TripWired


1 Answers

This might work for you:

<div class="${(sec.isLoggedIn()?loggedInClass:null)}">

Or Try this:

<div class="${(sec.isLoggedIn()?'loggedInClass':'null')}">
like image 152
Naftali Avatar answered May 15 '26 17:05

Naftali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!