Using markup with the render is not adding the form tag.
I tried this with contentType "text/h开发者_开发技巧tml", "txt/xml" and it does not work.
I have this in my controller:
def myTest= {
render(contentType: "text/plain") {
div(id:"myDiv") {
p "somess text inside the div"
form (action:'get') {
p "inside form"
}
}
}
And I'm getting this:
<div id='myDiv'><p>somess text inside the div</p><p>inside form</p></div>
I want this:
<div id='myDiv'><p>somess text inside the div</p><form><p>inside form</p></form></div>
Does anybody know why is not adding the form and how to add it?
Thanks,
Federico
i found this problem earlier and the work around was to use the builder directly
def test = {
def sw = new StringWriter()
def b = new MarkupBuilder(sw)
b.html(contentType: "text/html") {
div(id: "myDiv") {
p "somess text inside the div"
b.form(action: 'get') {
p "inside form"
}
}
}
render sw
}
will render the following HTML
<html contentType='text/html'>
<div id='myDiv'>
<p>somess text inside the div</p>
<form action='get'>
<p>inside form</p>
</form>
</div>
</html>
精彩评论