Grails: Call taglib from g:if tag

一笑奈何 提交于 2019-11-29 12:09:24

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!