org.codehaus.groovy.grails.web.taglib
Class LayoutWriterStack
java.lang.Object
org.codehaus.groovy.grails.web.taglib.LayoutWriterStack
public class LayoutWriterStack
- extends java.lang.Object
Class that can be used by "layout" tags, i.e. tags that use the different parts in their body to assemble a bigger part.
Example a threeColumn tag that expects a left, center and right part in its body and places them in a table:
<g.threeColumn>
<g.left>left contents</g.left>
<g.center>middle contents</g.center>
<g.right>right contents</g.right>
</g.threeColumn>
|
Method Summary |
static java.io.Writer |
currentWriter(java.lang.String name)
Returns a Writer where a layout part can write its contents to. |
static java.util.Map<java.lang.String,java.lang.Object> |
writeParts(groovy.lang.Closure<?> body)
Executes the body closure of a tag and returns a Map with namned results that hold the content of the parts within the body. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LayoutWriterStack
public LayoutWriterStack()
currentWriter
public static java.io.Writer currentWriter(java.lang.String name)
- Returns a
Writer where a layout part can write its contents to.
This method should only be called by tags that are part of a surrounding layout tag.
Example:
def left = { attrs, body ->
LayoutWriterStack.currentWriter('left') << "<div class='left'>" << body() <<"</div>"
}
- Parameters:
name - Name of the layout part
- Returns:
- writer
writeParts
public static java.util.Map<java.lang.String,java.lang.Object> writeParts(groovy.lang.Closure<?> body)
- Executes the body closure of a tag and returns a Map with namned results that hold the content of the parts within the body.
This method should only be called by tags that are part of a surrounding layout tag.
Example:
def parts = LayoutWriterStack.writeParts(body)
out << "left part:" << parts.left << "; right part:" << parts.right << ";remainder of body:" << parts.body
- Parameters:
body - the body closure of the calling "layout" tag
- Returns:
- a Map that contains the results of all the parts in the body and the body itself