Question

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.

Was it helpful?

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.

OTHER TIPS

In this context out refers to the output stream/writer. Typically this is going to be the GroovyPage from which it's called.

As far as using it, I'm not sure what you are looking for but your example is pretty complete. You can always browse the source code for the built in tags for Grails on Github.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top