Table

Use tables to implement <table>, <tr>, <th>, <td>, <thead>, <tbody> and <tfoot> tags.

Parameters

<table>, <tr>, <thead>, <tbody> and <tfoot> can take 2 optional configuration params. <th> and <td> tags can also take a third param, text input.

id (optional)

Expects a string with all ids the element should have.

class (optional)

Expects a string with all classes the element should have.

text (optional)

Expects a string which will be rendered between the opening and closing <th> or <td>-tag

Example 1

Implementing a simple, hard coded table.

table class: "foo" do
  thead do
    tr class: "bar" do
      th text: "First"
      th text: "Matestack"
      th text: "Table"
    end
  end
  tbody do
    tr do
      td text: "One"
      td text: "Two"
      td text: "Three"
    end
    tr do
      td text: "Uno"
      td text: "Dos"
      td text: "Tres"
    end
  end
  tfoot do
    tr do
      td text: "Eins"
      td text: "Zwei"
      td text: "Drei"
    end
  end
end

returns

Example 2

The real beauty comes into play when things get a little more complicated

returns

Example 3

thead, tbody and tfoot are optional containers for any number of trs. If none are specified, tbody will be used to contain all tr components. thead is typically used for the head of the table, and tfoot for any table footer, where applicable, such as a sum or count.

returns

Last updated

Was this helpful?