The background is:
- I have layout page main.gsp
- I need to conditionally show or hide menu item
- Condition evaluation is done by querying database
- I don’t want to augment each controller so it will evaluate this condition and put result to the model
The issue is:
I’m trying to do something like that
<g:if test="${checkCondition()}"> some html here </g:if>
But it fails saying that checkCondition in undefined.
But this works perfectly:
<mytaglib:checkCondition />
The question is:
What should I do to be able to call my function within
<g:if test="${ expression }">
?
Since you have the tag in a namespace (‘mytaglib’) you need to call it as a method with that namespace too: