I'm using the pageProperty function to drive some of my menus that are in my layout. I need to apply specific classes to links depending on which meta.nav pageProperty returns. Right now, it looks like this...
<g:if test="${pageProperty(name:'meta.nav') == 'support'}">
<g:link class="selected" ...>support</g:link>
</g:if>
<g:else>
<g:link ...>support</g:link>
</g:else>
I'd like to clean this up, however, this does not work
<g:link class="${pageProperty(name:'meta.nav') == 'support' ? selected : null}" ...>support</g:if>
I've tried several different variations of paranthesis and none seem to get what I need. For example:
${(pageProperty(name:'meta.nav') == 'support') ? selected : null}
${(pageProperty(name:'meta.nav') == 'support' ? selected : null)}
Just can't seem to get it to act right. Any help is appreciated.
As a wild stab in the dark, how about:
${ pageProperty(name:'meta.nav').equals( 'support' ) ? 'selected' : null }
Not as groovy, but might be less confusing to the parser (it looks like something somewhere is getting confused and dumping == support
out where it shouldn't)