Hypermedia

Latest version: v5.3.3

Safety actively analyzes 706267 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 3

5.0.0

Breaking

We need a way to handle html attributes like `hx-on:click` or `any_weird.format`. At the same time I want it to be easy to add attributes. I've decided to let all kwargs added normally like `data_test` where no `Alias` is defined will have its underscores replaced with hyphens. Any kwarg that has a `$` prefix, will be outputted as is minus the `$`. This kwarg can only have been added by spreading a dict into the constructor, so we can assume that it is done on purpose.

* Any attribute that does not have an Alias will have any underscores (`_`) changed to hyphens (`-`).
* Any attribute that is prefixed with `$` will be outputted as is without the first `$`.

ie

python
Is a specified attribute(typed) with an Alias:
Div(on_afterprint="test") <div onafterprint='test'></div>
Unspecified attribute without Alias:
Div(data_test="test") <div data-test='test'></div>
Spread without $ prefix gets its underscores changed to hyphens.
Div(**{"funky-format_test.value": True}) <div funky-format-test.value></div>
Spread with $ prefix
Div(**{"$funky-format_test.value": True}) <div funky-format_test.value></div>
Div(**{"$funky-format_test.value": "name"}) <div funky-format_test.value='name'></div>


Feature

* `classes` and `class_` attributes are now merged.

python
def test_class_and_classes_are_combined() -> None:
element = TestElement(class_="three", classes=["one", "two"])

assert element._render_attributes() == " class='one two three'"

4.1.0

Feature

Added types for html elements and their attributes. The type system is taken from [Ludic.](https://github.com/getludic/ludic). It is just so incredibly good. This gives us autocomplete support for everything.

* Types html elements and attributes.

Internal

* Document how to add attributes with symbols like dash and period.

4.0.0

Breaking

Instead of having to use `text` and `composed_text` keywords you can now write text like this:

python
Div("My text", Bold("My bold text"), "Tail")


* Removes `text` argument.
* Removes `composed_text` argument.

Features

* The direct `*args` are now is a list of `Element | str`. This is basically exactly how `composed_text` worked, If we have a string child, we escape it, otherwise we call the child Elements `.dump()`. This should be a lot smoother to work with and read.

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

2.2.0

Features

* Escape all text by default.
* Add `composed_text` property that takes a list of strings or Elements and dumps that. This can be used to render strings with inline elements like `<br>`, `<i>` or `<b>`. used like: `composed_text=["regular", Italic(text="italic"), Bold(text="bold"), "regular"]`

Internal

* Test elements with custom dump override like `Docstring` and `Comment` for string escaping.
* Add tests to composed_text.

2.1.2

* Expose models directly in `__init__` file for typing/extension purposes.
* 11 Ignore `None` valued attributes. This makes for easier programming.
* Properly Type attributes (an elements kwargs) `str | bool | None`.
* Improve test coverage.

Page 2 of 3

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.