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, Menu, Navbar, Breadcrumb, ValidationSummary) for
which components are hand-written instead and why.
Install
pip install fastblocks-htmy # pulls fastblocks-ui (>=0.7,<0.8) 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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastblocks_htmy-0.4.0.tar.gz.
File metadata
- Download URL: fastblocks_htmy-0.4.0.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8a65fc3c6546a5339baaebc1886d36fb5d713c82c70e1ea805e56979e94a011
|
|
| MD5 |
2d748b13b919eecef7bdb088e3b1c90b
|
|
| BLAKE2b-256 |
f8965297a42976d8574e414f630267d17ba1e0067934d7dca8d65f00b8d96721
|
File details
Details for the file fastblocks_htmy-0.4.0-py3-none-any.whl.
File metadata
- Download URL: fastblocks_htmy-0.4.0-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b3dd40b1762399a42302597b172689138afa92bc4805e690fe589041f792c21
|
|
| MD5 |
94503be17f2a5315c555bdb633efc599
|
|
| BLAKE2b-256 |
a7cc7adc881451ce0d4f47870cb05edca187f62181d925e4835597552f601eb9
|