开发者

Inline if statement in grails

Is there a way in Grails to do condi开发者_如何学编程tionals 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.


This might work for you:

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

Or Try this:

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


You can do:

<div class="${sec.loggedIn ? 'loggedInClass' : ''}">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜