AshReports.Layout.IR.Content (ash_reports v0.1.0)

Intermediate Representation for content elements.

This module defines IR types for content that can appear within cells:

  • LabelIR - Static text content
  • FieldIR - Dynamic field values with formatting
  • NestedLayoutIR - Nested layout containers

Content Union Type

The t() type is a union of all content types, making content polymorphic within cells.

Examples

# Label content
label = AshReports.Layout.IR.Content.label("Total:", style: %{font_weight: :bold})

# Field content
field = AshReports.Layout.IR.Content.field(:amount,
  format: :currency,
  decimal_places: 2
)

# Nested layout
nested = AshReports.Layout.IR.Content.nested_layout(grid_ir)

Summary

Functions

Returns the type of content IR.

Creates a field content IR.

Creates a label content IR.

Creates a nested layout content IR.

Types

field_ir()

@type field_ir() :: %AshReports.Layout.IR.Content.Field{
  source: atom() | [atom()],
  format: atom() | nil,
  decimal_places: non_neg_integer() | nil,
  style: AshReports.Layout.IR.Style.t() | nil
}

label_ir()

@type label_ir() :: %AshReports.Layout.IR.Content.Label{
  text: String.t(),
  style: AshReports.Layout.IR.Style.t() | nil
}

nested_layout_ir()

@type nested_layout_ir() :: %AshReports.Layout.IR.Content.NestedLayout{
  layout: AshReports.Layout.IR.t()
}

t()

Functions

content_type(arg1)

@spec content_type(t()) :: :label | :field | :nested_layout

Returns the type of content IR.

Examples

iex> AshReports.Layout.IR.Content.content_type(%AshReports.Layout.IR.Content.Label{})
:label

field(source, opts \\ [])

Creates a field content IR.

Options

  • :format - Format type (:number, :currency, :date, etc.)
  • :decimal_places - Number of decimal places for numeric formats
  • :style - StyleIR for field styling

Examples

iex> AshReports.Layout.IR.Content.field(:amount, format: :currency)
%AshReports.Layout.IR.Content.Field{source: :amount, format: :currency, ...}

label(text, opts \\ [])

Creates a label content IR.

Options

  • :style - StyleIR for text styling

Examples

iex> AshReports.Layout.IR.Content.label("Hello")
%AshReports.Layout.IR.Content.Label{text: "Hello", style: nil}

nested_layout(layout)

Creates a nested layout content IR.

Examples

iex> grid_ir = AshReports.Layout.IR.grid()
iex> AshReports.Layout.IR.Content.nested_layout(grid_ir)
%AshReports.Layout.IR.Content.NestedLayout{layout: %AshReports.Layout.IR{...}}