grailsgroovygrails-2.0gsptaglib

How out object work for custom tag library in grails?


In Grails i am using custom tag library, here is my code

def isCheck = { attrs, body ->
    def checkUser = springSecurityService.currentUser
    def owner = attrs?.owner

    if(checkUser?.id == owner?.id) {
        out << body()
    }
}

But here how the out object work.I think its from TagLibraryApi class.But without any initialization how it's work.
can anyone give me the concept for using out object.


Solution

  • From the Grails docs:

    there is an implicit out variable that refers to the output Writer which you can use to append content to the response

    Think of it like a field from a super class that you are referencing.