Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using MarkupBuilder to generate html markup in groovy
// MarkupBuilder is a lot cleaner way of generating valid xml/html markup
// than writing tags as string and forgetting to close one ;)
def writer = new StringWriter() // html is written here by markup builder
def markup = new groovy.xml.MarkupBuilder(writer) // the builder
table {
tr {
td(class:"row", "hello world!")
println writer.toString()
/* produces output :
<td>hello world!</td>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment