I am trying to use j2html to render a really simple table, but I have gotten completely stuck on the nesting and can not find any docs for this.
Trying to keep this short and to the point, this is the exact html that I want to achieve:
<table border=0>
<tr>
<td style="vertical-align: top">
<b>Some Info:</b>
</td>
<td style="vertical-align: top">
<p>"some fetched info"</p>
</td>
</tr>
</table>
Now, what I wrote is this (note that this is one of many attempts):
table(),
tr(
b("Some Info: "),
td().withStyle("vertical-align: top").withText("some fetched info")),
br()
The result I get is:
<body>
<table>
</table>
<tr>
<b>Some Info: </b>
<td style="vertical-align: top">Some fetched info
</td>
</tr>
I can not seem to get a grasp of the proper nesting for this problem (or how to add the table border attribute for that matter).
I wrote a very short example here hoping that someone could help, thinking that if I just get this one right the whole thing will probably click in my brain.
(Realizing just now I can't close the table bracket that way...)
You would need to nest the
tr
within thetable
. Also, you can't haveb("Some Info: ")
directly withintr
, it needs to be nested inside atd
. Here is how the code should look: