JakeWharton / picnic

A Kotlin DSL and Java/Kotlin builder API for constructing HTML-like tables which can be rendered to text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: render an empty footer

vRallev opened this issue · comments

Imagine this table

        table {
          style {
            borderStyle = Solid
          }
          cellStyle {
            borderLeft = true
            borderRight = true
          }
          header {
            cellStyle {
              border = true
              alignment = BottomLeft
            }
            row("Header 1", "Header 2")
          }
          body {
            repeat(3) {
              row("row $it", "row $it")
            }
          }
        }

It would render:

┌────────┬────────┐
│Header 1│Header 2│
├────────┼────────┤
│row 0   │row 0   │
│row 1   │row 1   │
│row 2   │row 2   │

Notice that the border at the bottom is missing. The fix is could be to render a different row in the body

            row {
              cell("last row") {
                borderBottom = true
              }
              cell("last row") {
                borderBottom = true
              }
            }

Or another fix could be to render a footer:

          footer {
            cellStyle {
              borderBottom = true
            }
            row("Footer 1", "Footer 2")
          }

But this is annoying, because the last row is a special case. I'd rather would like to specify a footer like this:

          footer {
            cellStyle {
              border = true
            }
          }

But this doesn't render anything since there is no row.

I think this is solved by #13 (fixed by #14) in 0.3.0.

Basically you just need to set

style {
  border = true
}

on the table and you should be good.

I missed that, it works as expected.

Great!