...
Code Block |
---|
response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); log.info "Groovin' on ${resource}" def mb = new groovy.xml.MarkupBuilder(out) mb.html { def tableForMap = { cap, map -> table { caption { h2 cap } tr { td { h3th 'property' } ; td { h3th 'value' } } map.each { key, value -> tr { td key ; td value } } } } meta { title 'Groovy Scripting Sample for Sling' } body { h1 "Hello World !" p "This is Groovy Speaking" p "You requested the Resource ${resource} (yes, this is a GString)" table { caption { h2 'Current Node Properties' } tr { td { h3th 'property' } ; td { h3th 'value' } } currentNode.properties.each { prop -> tr { td prop.name ; td prop.string } } } tableForMap 'Resource Properties', resource.properties tableForMap 'Script Bindings', this.binding.variables tableForMap 'Request Properties', request.properties } } |
...