Documentation
¶
Overview ¶
Package blocks defines the fixed library of display building blocks used to compose a template's rendered layout. A Block is a discriminated union: Type selects the payload shape and Data holds the matching json.RawMessage, produced by a New* constructor and read back with the matching As* accessor.
Index ¶
- Variables
- type Block
- func NewChart(kind string, labels []string, values []float64) Block
- func NewCode(lang, content string) Block
- func NewHeading(level int, text string) Block
- func NewKeyValue(pairs []KVPair) Block
- func NewList(ordered bool, items []string) Block
- func NewMetric(label, value, unit string) Block
- func NewTable(columns []string, rows [][]string, footer []string) Block
- func NewText(markdown string) Block
- func (b Block) AsChart() (Chart, error)
- func (b Block) AsCode() (Code, error)
- func (b Block) AsHeading() (Heading, error)
- func (b Block) AsKeyValue() (KeyValue, error)
- func (b Block) AsList() (List, error)
- func (b Block) AsMetric() (Metric, error)
- func (b Block) AsTable() (Table, error)
- func (b Block) AsText() (Text, error)
- type BlockType
- type Chart
- type Code
- type Document
- type Heading
- type KVPair
- type KeyValue
- type List
- type Metric
- type Table
- type Text
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBlockTypeMismatch = errors.New("block type mismatch")
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
Type BlockType `json:"type"`
Data json.RawMessage `json:"data"`
}
Block is a discriminated union over the display building blocks. Data holds the payload matching Type, as json.RawMessage.
func NewHeading ¶
func NewKeyValue ¶
func (Block) AsKeyValue ¶
type BlockType ¶
type BlockType string
BlockType identifies which payload shape a Block's Data holds.
type Document ¶
type Document = []Block
Document is an ordered sequence of Blocks composing a rendered layout.
Click to show internal directories.
Click to hide internal directories.