Consider the following code:
def builder = new MarkupBuilder()
builder.root() {
}
I would like to delegate creation of the children of root to a separate method. How can I accomplish this task? Some options to consider are creating and returning a node from a method or passing in the parent node and adding them in the method (both examples would be useful).
The Groovy website contains an explanation on how to achieve this.
Sample:
Output will be: