I have a custom tag lib that returns a Boolean object so that my GSP can decide whether to display a piece of html or not. I would like to use the g:if tag to check this Boolean's value since I also need to check a few other values (that aren't accesible in the taglib). However, I don't know how to actually call the taglib from the tag?
I've tried:
<g:if test="${<custom:tag/> && other.boolean}">
but that throws errors.
I also tried:
<g:if test="<custom:tag/> && ${other.boolean}">
but that throws errors too.
How does the taglib look like? Looking at the usage it should be as below:
class SomeTagLib {
static namespace = "custom"
static returnObjectForTags = ['tag']
def tag = { attrs, body ->
//returns an object (can be boolean)
}
}
By default, taglibs would return StreamCharBuffer. If you need an object to be returned, (as in your case to be used as part of conditional statement), I guess you would need returnObjectFromTags
as shown above. It specifies which tag deviates from default behavior and returns an object instead.
Also, you should be using the taglib as mentioned by Tim:
<g:if test="${custom.tag() && other.boolean}"> //should be the appropriate way
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With