Core Concepts
htmforge is built in three layers:
- Layer 1: Element
Elementrepresents a single HTML tag and implementsto_html().- Attribute mapping rules:
cls→class,for_→for,hx_get→hx-get. -
Boolean
Truerenders as a flag,None/Falseare omitted. -
Layer 2: Component
Componentis apydantic.BaseModelwith an abstractrender().to_html()delegates torender()and returns the full HTML string.-
htmx_attrs()collects only sethx_*properties and serializes dicts. -
Layer 3: Ready-made components
- Reusable high-level components (Badge, Breadcrumb, Modal, etc.)