Skip to content

Releases: thomasborgen/hypermedia

5.3.3

08 Nov 09:05
fb30a93
Compare
Choose a tag to compare

Version 5.3.3

  • Fixes bug with svg element dumping. (#48)[https://github.com//issues/48]

5.3.2

25 Sep 19:05
1122a76
Compare
Choose a tag to compare

Version 5.3.2

  • Fixes style attribute rendering.

5.3.1

22 Sep 07:10
f052367
Compare
Choose a tag to compare

Version 5.3.1

  • Adds lang as an attribute to the Html element.

5.3.0 - SafeString - Bypass html escaping

26 Aug 10:26
ca27349
Compare
Choose a tag to compare

Version 5.3.0

Feature

  • Adds SafeString type as a wrapper around the normal str class. This can be used to tell hypermedia not to html.escape the string in any element.
Div("this is always escaped")
Div(SafeString("This will not be escaped"))
  • Hypermedia is now cachable - All calls to .dump() now returns a SafeString. This means that caching a dumped element is now possible because we won't call html.escape on it again.
@lru_cache()
def stylesheets() -> SafeString:
    return ElementList(
        Link(
            rel="stylesheet",
            href="/static/css/normalize.css",
            type="text/css",
        ),
        Link(
            rel="stylesheet",
            href="/static/css/simple.min.css",
            type="text/css",
        )
    ).dump()

def base():
    """
    Once `stylesheets()` is called once, it will always use the cached String in subsequent
    calls to `base()`
    """
    return ElementList(
        Doctype(),
        Html(
            Head(
                Meta(charset="UTF-8"),
                stylesheets(),
                slot="head",
            ),
            Body(...)
            lan="en",
        ),
    )
  • Script and Style elements wraps input in SafeString by default.
Script("This is wrapped in `SafeString` by default")
Style("This is wrapped in `SafeString` by default")

5.2.0 - Hyperscript

19 Aug 11:48
bd67061
Compare
Choose a tag to compare

What's Changed

Version 5.2.0

Feature

  • Can now use hyperscript with the _ attribute that renders as: _='value' by @thomasborgen in #35

Fix

  • Fix missing Alias for the for_ attribute. It now renders correctly as for='value' by @thomasborgen in #36

Full Changelog: 5.1.0...5.2.0

5.1.0

12 Aug 21:43
fc88926
Compare
Choose a tag to compare

Version 5.1.0

Fix

  • Calling dump(), more specifically render_attributes() popped out class_ and classes attributes from the element. So subsequent calls would be missing the attributes. This fixes that. PR

Full Changelog: 5.0.0...5.1.0

5.0.0

10 Aug 18:35
b5ca189
Compare
Choose a tag to compare

Version 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

# 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>
# Spreaded without $ prefix gets its underscores changed to hyphens.
Div(**{"funky-format_test.value": True})  # <div funky-format-test.value></div>
# Spreaded 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.
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 Types and Autocompletion

10 Aug 10:52
802647c
Compare
Choose a tag to compare

Version 4.1.0

Feature

Added types for html elements and their attributes. The type system is taken from Ludic.. It is just so incredibly good. This gives us autocomplete support for everything.

  • Types html elements and attributes.

Documentation

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

4.0.0

05 Aug 20:33
c8785ed
Compare
Choose a tag to compare

Breaking

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

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

05 Aug 08:13
bfc4499
Compare
Choose a tag to compare

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

Full Changelog: 2.2.0...3.0.0