Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6.4, 1.7-beta-1
-
None
-
None
-
win 7 64, java 1.6.0_16/64
Description
I have this simple test script:
import groovy.xml.* def out = new StringWriter() def mkp = new MarkupBuilder(out) mkp.table(id: 'psds', border: 0) { tbody { tr { td(id: 999) { mkp.yield 999 } td(id: 99) { mkp.yieldUnescaped 99 } td(id: 88) { mkp.yieldUnescaped 'hello' } td(id: 77) { mkp.yieldUnescaped "hello2" } td(id: 66) { mkp.yieldUnescaped """hello3""" } // gives compilation error "unexpected token: } at line: 12, column: 52": td(id: 55) { mkp.yieldUnescaped /hello4/ } } } } println out.toString()
This gives:
<table id='psds' border='0'> <tbody> <tr> <td id='999'> <yield>999</yield> </td> <td id='99'> <yieldUnescaped>99</yieldUnescaped> </td> <td id='88'>hello</td> <td id='77'>hello2</td> <td id='66'>hello3</td> </tr> </tbody> </table>
IMHO: there are a couple of issues here...
- The behaviour of yield/yieldUnescaped with non-strings
The methods should not surround the values with <yield>...</yield>, etc.
With HTML this is a nuisance, but if one were trying to validate against an XML schema, this would be disastrous.
- The compilation error with slashy strings