Skip to content

Commit

Permalink
Rename htmx.py file to fastapi.py file (#17)
Browse files Browse the repository at this point in the history
* Rename htmx.py file to fastapi.py file

* update safety
  • Loading branch information
thomasborgen authored Aug 5, 2024
1 parent 6b50eff commit bfc4499
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 56 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

## Latest Changes

## Version 3.0.0

### Breaking

* Rename `htmx.py` to `fastapi.py`. The decorators were only for fastAPI. If we support django or flask, then they should get their own versions. This change facilitates for that so we don't have to have a breaking change further down the line.
* Don't expose `@htmx` and `@full` decorators directly from `hypermedia`, but require them to be imported from `hypermedia.fastapi`.

### Housekeeping

* Readme file: Add features section, improve examples
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ HTMX provides an `HX-Request` header that is always true. We can check for this

We've chosen to implement that check in a `@htmx` decorator. The decorator expects `partial` and optionally `full` arguments in the endpoint definition. These must be resolved by FastAPI's dependency injection system.

```python
from hypermedia.fastapi import htmx, full
```

The `partial` argument is a function that returns the partial HTML.
The `full` argument is a function that needs to return the whole HTML, for example on first navigation or a refresh.

Expand Down
4 changes: 0 additions & 4 deletions hypermedia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
TextArea,
)
from hypermedia.frames import IFrame
from hypermedia.htmx import full, htmx
from hypermedia.images import (
Area,
Canvas,
Expand Down Expand Up @@ -183,9 +182,6 @@
# Models
"Element",
"ElementList",
# HTMX
"htmx",
"full",
# audio and video
"Audio",
"Source",
Expand Down
2 changes: 1 addition & 1 deletion hypermedia/htmx.py → hypermedia/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def wrapper(
def full(
func: Callable[Param, ReturnType],
) -> Callable[Param, Coroutine[Any, Any, Callable[[], ReturnType]]]:
"""Wrap the paru full page render dependency and makes it lazy."""
"""Wrap the full page render dependency and makes it lazy."""

@wraps(func)
async def wrapper(
Expand Down
Loading

0 comments on commit bfc4499

Please sign in to comment.