Created
October 7, 2010 22:21
-
-
Save coderberry/616027 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class CommonTagLib { | |
| static namespace = 'berry' | |
| def formatXML = { attrs, body -> | |
| String rawXML = body().toString() | |
| try { | |
| def slurpedXML = new XmlSlurper().parseText(rawXML) | |
| def writer = new StringWriter() | |
| new XmlNodePrinter(new PrintWriter(writer)).print(slurpedXML) | |
| def formattedResponse = writer.toString() | |
| out << formattedResponse | |
| } catch(Exception e) { | |
| log.info "Unable to parse XML: ${e.message}" | |
| out << rawXML | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment