Using Curry to Define Grails Tags

I have a grails TpTagLib tag library and in it I want to define 4 new tags that differ by only one constant value, so I tried using curry. But there is an exception: groovy.lang.MissingPropertyException: There is no such property: attr for the class: TpTagLib

Does anyone know why this exception occurs? Here is the code:

def ifPermsTag = { permissions, attr, body ->
    def user = attr?.user ?: session.userInstance
    if( !user ) return false
    if( !securityService.hasPermissions(user,permissions) ) return false
        out << body()
    return true
}


def canAdminRequestmaps = ifPermsTag.curry(Permission.CAN_ADMIN_REQUESTMAPS)
def canAdminCorporations = ifPermsTag.curry(Permission.CAN_ADMIN_CORPS)
def canAdminUsers = ifPermsTag.curry(Permission.CAN_ADMIN_USERS)    
def canAdminDevices = ifPermsTag.curry(Permission.CAN_ADMIN_DEVICES)    
+3
source share
1 answer

Cold appliances. You just need to make ifPermsTag private so that it does not consider the candidate suitable for using the tag method:

private ifPermsTag = { permissions, attr, body ->
...
}

"attr" "attr" "body", .

+3

Source: https://habr.com/ru/post/1716761/


All Articles