lab42_html

Build StatusCoverage StatusHex.pmHex.pmHex.pm

Synopsis

An isolated HTML generator. Inspired in its simplicity by Dave Thomas' keynote, condensed here https://pragdave.me/blog/2018/06/02/project-structure.html

Lab42.Html.gen_table/2

iex(0)> data = [
...(0)> ["header1", "header2"],
...(0)> ["cell1", "cell2"]]
...(0)> gen_table(data)
{:ok, "<table>\n<thead>\n<tr>\n<th>\nheader1\n</th>\n<th>\nheader2\n</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>\ncell1\n</td>\n<td>\ncell2\n</td>\n</tr>\n</tbody>\n</table>\n", []}

Headers can, but probably shall not, be avoided, also we expose Lab42.Html.Table.gen/2 as gen_table/2

iex(1)> data = [
...(1)> ~w(no_header no_header),
...(1)> ~w(cell21 cell22)]
...(1)> gen_table(data, false)
{:ok,
"<table>
no_header no_header cell21 cell22 ", []}

Author

Copyright © 2019 Robert Dober, mailto:robert.dober@gmail.com

License

Apache-2.0