Method: Faker::HTML.table

Defined in:
lib/faker/default/html.rb

.tableString

Produces a random HTML table.

Examples:

Faker::HTML.table #=> "<table>\n<thead>\n<th>ad</th>\n<th>similique</th>\n<th>voluptatem</th>\n</thead>\n<tbody>\n<td>corrupti</td>\n<td>est</td>\n<td>rerum</td>\n<td>molestiae</td>\n<td>quidem</td>\n<td>et</td>\n<td>in</td>\n<td>tempora</td>\n<td>at</td>\n<\tbody>\n<tfoot>\n<td>voluptatem</td>\n<td>debitis</td>\n<td>rem</td>\n</tfoot>\n</table>"

Returns:



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/faker/default/html.rb', line 112

def table
  header_row = generate_table_row('th', 3)
  footer_row = generate_table_row('td', 3)

  body_rows = []
  3.times do
    row = generate_table_row('td', 3)
    body_rows << row
  end

  thead = "<thead>\n#{header_row}</thead>"
  tbody = "<tbody>\n#{body_rows.join("\n")}</tbody>"
  tfoot = "<tfoot>\n#{footer_row}</tfoot>"

  "<table>\n#{thead}\n#{tbody}\n#{tfoot}\n</table>"
end