tipsy / j2html

Java to HTML generator. Enjoy typesafe HTML generation.

Home Page:https://j2html.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding custom(non-supported) attrs in td

rajjaiswalsaumya opened this issue · comments

commented

How to use data-label attr for td. I want to create a table like this.

Statement Summary
Account Due Date Amount Period
Hi
Visa - 3412 04/01/2016 $1,190 03/01/2016 - 03/31/2016
Visa - 6076 03/01/2016 $2,443 02/01/2016 - 02/29/2016
Corporate AMEX 03/01/2016 $1,181 02/01/2016 - 02/29/2016
Visa - 3412 02/01/2016 $842 01/01/2016 - 01/31/2016
commented

There is a general attr(String attribute, String value) method, which will let you create whatever custom attributes you want.

commented

I need to add caption tag in table. Please suggest how to do that.
example

<table>
    <caption>Statement Summary</caption>
    <thead>
    <tr>
        <th scope="col">Account</th>
        <th scope="col">Due Date</th>
        <th scope="col">Amount</th>
        <th scope="col">Period</th>
    </tr>
    </thead>
    <tfoot>
    <tr>
        <td colspan="4">
            Hi
        </td>
    </tr>
    </tfoot>
    <tbody>
    <tr>
        <td data-label="Account">Visa - 3412</td>
        <td data-label="Due Date">04/01/2016</td>
        <td data-label="Amount">$1,190</td>
        <td data-label="Period">03/01/2016 - 03/31/2016</td>
    </tr>
    <tr>
        <td scope="row" data-label="Account">Visa - 6076</td>
        <td data-label="Due Date">03/01/2016</td>
        <td data-label="Amount">$2,443</td>
        <td data-label="Period">02/01/2016 - 02/29/2016</td>
    </tr>
    <tr>
        <td scope="row" data-label="Account">Corporate AMEX</td>
        <td data-label="Due Date">03/01/2016</td>
        <td data-label="Amount">$1,181</td>
        <td data-label="Period">02/01/2016 - 02/29/2016</td>
    </tr>
    <tr>
        <td scope="row" data-label="Acount">Visa - 3412</td>
        <td data-label="Due Date">02/01/2016</td>
        <td data-label="Amount">$842</td>
        <td data-label="Period">01/01/2016 - 01/31/2016</td>
    </tr>
    </tbody>
</table>
commented
table(
    caption("Statement summary"),
    thead(
        tr(
            th("A"),
            th("B")
        )
    ),
    tbody(
        tr(
            td("1"),
            td("2")
        )
    )
)