FastBlocks htmy
Type-safe htmy components and a FastBlocks adapter
built on top of the fastblocks-ui
design system.
fastblocks-htmy is the FastBlocks-native layer: where fastblocks-ui ships the
CSS and zero-dependency string helpers, this package wraps them in typed, composable
htmy components and provides the adapter that registers assets and template globals
with a FastBlocks app (ACB [[ ]] delimiters).
Design principle: this is a thin wrapper. It never reimplements styling — every component renders the corresponding
fastblocks-uihelper output wrapped in htmy'sSafeStr. A parity test enforces that the two layers can't diverge.
Status
All 27 fastblocks-ui manifest components (including validation_summary) now have
a typed htmy wrapper, plus the FastBlocks adapter (asset_paths, asset_urls,
template_globals, trusted_components). Button, Container, Table, and Field
were hand-written first (Phase 1); the rest were added by WS-16's manifest-driven
codegen (scripts/generate_components.py) — see fastblocks_htmy/ui/_generated.py
and fastblocks_htmy/layout/_generated.py, and each carve-out module's docstring
(Columns, Select, Tabs, Dropdown, Navbar, Breadcrumb, NavList,
NavGroups, ValidationSummary) for
which components are hand-written instead and why.
Install
pip install fastblocks-htmy # pulls fastblocks-ui (>=0.8,<0.9) and htmy
Usage
import asyncio
from htmy import Renderer
from fastblocks_htmy import Button
html = asyncio.run(Renderer().render(Button("Save", variant="primary")))
# -> '<button class="ui-button is-primary" type="button">Save</button>'
FastBlocks integration
Status note (unverified against a live FastBlocks app as of this writing — see the
integration test in tests/test_fastblocks_integration.py for what's actually
confirmed). Two integration paths exist with different maturity:
-
String helpers as plain Jinja globals — the path most likely to already work.
ui_button/ui_card/ui_field/ui_alert(and the rest offastblocks_ui's exports) are ordinary functions returning strings. Registered viatemplates.env.globals.update(template_globals())on FastBlocks' plain Jinja2 adapter, calling them from a template is no different from calling any other Jinja global function:from fastblocks_htmy.fastblocks import asset_paths, asset_urls, template_globals # Mount the shipped fastblocks-ui assets (resolved from the installed wheel): app.mount("/static/fastblocks-ui", StaticFiles(directory=asset_paths()["root"])) # Register components + helpers as template globals (cache-busted asset URLs included): templates.env.globals.update(template_globals())
<link rel="stylesheet" href="[[ fastblocks_ui_css ]]"> [[ ui_button(text="Save", variant="primary") ]]
-
Typed htmy components used directly as
[[ Button(...) ]]template expressions — do not rely on this yet. Two independent issues mean this is not known to work as a bare template expression today:- FastBlocks' real htmy component-loading path discovers components from
.pysource files under atemplates/<app>/components/search path, validated by a sandboxed AST loader that only allowsdataclasses/typingas top-level imports. Every component infastblocks_htmy/ui/andfastblocks_htmy/layout/importsfastblocks_ui,htmy, and..base— all of which that loader would reject if these files were dropped into a discovered-components directory as-is. - Independently of the above, a bare instantiated component handed to a
template engine's normal output mechanism only renders correctly if
something actually calls
.htmy(context)on it (which is what FastBlocks'render_component()template global does).FastBlocksComponentnow provides a best-effort__str__/__html__fallback so accidental bare stringification doesn't print a dataclass repr, but this has not been proven against FastBlocks' realrender_component()-mediated rendering path with a passing integration test yet.
Until that's resolved (tracked in
fastblocks-ui's roadmap under the cross-repo remediation plan), prefer path 1 above for anything rendered through an actual FastBlocks template. The typed components remain fully usable via directRenderer().render(...)calls, as this package's own tests do. - FastBlocks' real htmy component-loading path discovers components from
Relationship to fastblocks-ui
| Package | Role | Dependencies |
|---|---|---|
fastblocks-ui |
CSS + tokens + manifest + string helpers | none (zero runtime deps) |
fastblocks-htmy |
typed htmy components + FastBlocks adapter | fastblocks-ui, htmy |
See the architecture decision record in
fastblocks-ui/docs/roadmap.md.
License
BSD-3-Clause
Metadata
Release files for fastblocks-htmy 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastblocks_htmy-0.5.0.tar.gz | 27.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastblocks_htmy-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.1 kB
Release files / fastblocks_htmy-0.5.0.tar.gz
| Download URL | fastblocks_htmy-0.5.0.tar.gz |
|---|---|
| Size | 27.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
838c3b44883d1e5b6491c719f74c9a978119f5f0cca3208d89b68339a886eed9
|
|
BLAKE2b-256 checksum How to use checksums |
b5a414b1d961e327daf23fdb8ace4eafa43b466af2c7259e78b4b6745c023032
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / fastblocks_htmy-0.5.0-py3-none-any.whl
| Download URL | fastblocks_htmy-0.5.0-py3-none-any.whl |
|---|---|
| Size | 26.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b4dafebc9674f1b979418b353ebbacb565dcf3bab501556a175dabfff2aa296
|
|
BLAKE2b-256 checksum How to use checksums |
ab207fcec9f9ccfe37217b39eaee07a10e912bbbbad167c334e675d3c40cf837
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|