For example:
def list = {
books = Book.findAll(...)
render(contentType: 'text/xml') {
books(count: books.size()) {
for(book in books) {
book(id: book.id) {
title(book.title)
}
}
}
}
}
Using books and book as nodes cause naming conflicts. I understand I can rename everything to prevent the issue but is there a way to escape the nodes to prevent the issue and keep a clean naming convention?
Hubert Klein Ikkink has posted a blog entry with an alternate solution:
Groovy Goodness: Solve Naming Conflicts with Builders
He recommends prepending delegate to the node names so that example would become:
def list = {
books = Book.findAll(...)
render(contentType: 'text/xml') {
delegate.books(count: books.size()) {
for(book in books) {
delegate.book(id: book.id) {
title(book.title)
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With