Skip to content

Instantly share code, notes, and snippets.

@mike-neck
Created July 2, 2011 05:36
Show Gist options
  • Save mike-neck/1059763 to your computer and use it in GitHub Desktop.
Save mike-neck/1059763 to your computer and use it in GitHub Desktop.
Groovy Markup Builder for jquery mobile (Grid Records)
import groovy.xml.MarkupBuilder
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.html('lang' : 'ja'){
head{
meta('http-equiv' : 'Content-Type', 'content' : 'text/html; charset=UTF-8')
title('jQuery Mobile Sample')
link('rel' : 'stylesheet', 'href' : 'http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css')
['http://code.jquery.com/jquery-1.6.1.min.js', 'http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js'].each{
script('src' : it, ''){
}
}
}
body{
div('data-role' : 'page'){
div('data-role' : 'header'){
a('href' : '#', 'data-role' : 'button', 'data-icon' : 'back', 'data-rel' : 'back', 'Back')
h1('Grid Sample')
}
div('data-role' : 'content'){
[[1,2,3],[4,5,6],[7,8,9],['*','0','#']].each{ items ->
div('class' : 'ui-grid-b'){
items.eachWithIndex{item, indx ->
className = 'ui-block-' + sprintf("%c", 97 + indx)
div('class' : className){
a('href' : '#', 'data-role' : 'button', item)
}
}
}
}
}
div('data-role' : 'footer'){
['back' : 'back', 'arrow-u' : 'prev', 'arrow-d' : 'next', 'delete' : 'delete'].each{key, value ->
a('href' : '#', 'data-role' : 'button', 'data-icon' : key, value)
}
h1('mike_neck')
}
}
}
}
println '<!DOCTYPE html>'
println writer.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment