Created
January 20, 2011 09:33
-
-
Save miceno/787640 to your computer and use it in GitHub Desktop.
Groovy HTML DSL example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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