public class LayoutWriterStack
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>
Type Params | Return Type | Name and description |
---|---|---|
|
public static java.io.Writer |
currentWriter(java.lang.String name) Returns a java.io.Writer where a layout part can write its contents to. |
|
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. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Returns a java.io.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>"
}
name
- Name of the layout partExecutes 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
body
- the body closure of the calling "layout" tag