Harlock.Element.Column (harlock v0.2.0)

Copy Markdown View Source

Column spec for Harlock.Elements.table/1, built via Harlock.Elements.column/1:

column(title: "Name", width: {:fill, 1}, render: & &1.name)
column(title: "ID",   width: {:length, 4}, align: :right, render: & &1.id)

Fields:

  • :title — header label (shown when the table has show_header: true)
  • :width — layout constraint: {:length, n}{:percentage, p}
    {:fill, w}{:min, n}{:max, n}
  • :align:left (default) | :right | :center

  • :renderfn row -> String.t() | iodata(). Defaults to to_string/1 of the row itself, which is what makes Harlock.Elements.list/2 ergonomic (no render fn needed for simple lists).

Summary

Types

t()

@type t() :: %Harlock.Element.Column{
  align: :left | :right | :center,
  render: (any() -> String.t() | iodata()) | nil,
  title: String.t(),
  width: Harlock.Layout.constraint()
}

Functions

render_value(column, row)

@spec render_value(t(), any()) :: String.t()