user7071176
user7071176

Reputation:

Formatting html table using markupbuilder

How can I do something like this using groovy's markupbuilder.

<table border="1" cellpadding="5" cellspacing="0" width="200px" style="border- 
collapse:collapse;">

If I use this format below using a style in markupbuilder it produces totally different results. Is there a way to do the above in Markupbuilder without the style tag. I think that's what is causing it not to work correctly.

<table style='border:1; padding:5; width: 200px; border- 
collapse:collapse;'>

Upvotes: 1

Views: 2280

Answers (1)

cfrick
cfrick

Reputation: 37033

Sadly you didn't provide any code so we can only assume the error is in the map you pass the builder to the table tag. MarkupBuilder has no understanding of HTML and does not modify or optimize your code - so we can rule that out.

So here is an example to reproduce the HTML in your first example.

groovy:000> import groovy.xml.MarkupBuilder
===> groovy.xml.MarkupBuilder
groovy:000> writer = new StringWriter()
===> 
groovy:000> xml = new MarkupBuilder(writer)
===> groovy.xml.MarkupBuilder@1af687fe
groovy:000> xml.table(border: 1, cellpadding: 5, cellspacing: 0, width: "200px", style: "border-collapse:collapse")
===> table
groovy:000> print writer
<table border='1' cellpadding='5' cellspacing='0' width='200px' style='border-collapse:collapse' />===> null

Upvotes: 1

Related Questions