class BookTagLib {
def parent = { attrs, body ->
pageScope.parent = "John"
out << body()
}
def child = { attrs, body ->
out << "My parent is ${pageScope.parent}"
}
}
pageScope
Purpose
A reference to the binding of the GSP that the tag library is being executed within. Allows access to variables set with the set tag and those passed to the page from the controller model.
Examples
<g:parent>
<g:child /> // Outputs "My parent is John"
</g:parent>
Description
The pageScope
variable contains a reference to the underlying model being manipulated by the page. It can also be used to pass variables from parent to child tags.