Skip to content

Instantly share code, notes, and snippets.

@miceno
Created January 20, 2011 09:33
Show Gist options
  • Save miceno/787640 to your computer and use it in GitHub Desktop.
Save miceno/787640 to your computer and use it in GitHub Desktop.
Groovy HTML DSL example
// def writer = new FileWriter('markup.html')
def writer = new StringWriter()
def html = new groovy.xml.MarkupBuilder(writer)
html.html {
head { title 'Constructed by MarkupBuilder' }
body {
h1 'What can I do with MarkupBuilder?'
form (action:'whatever') {
for (line in ['Produce HTML','Produce XML','Have some fun'])
{
input(type:'checkbox',checked:'checked', id:line, '')
label(for:line, line)
br('')
}
}
}
}
// In case you would like to print it
print writer.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment