Skip to content

Releases: CheeseCake87/pyhead

5.3.1

17 Sep 08:24

Choose a tag to compare

Add crossorigin attribute to Link element

5.3.0

16 Sep 16:31

Choose a tag to compare

  • Small adjustments were done to how some elements compile
  • New type added to allow for the new functionality of FlaskUrlFor class

New

from pyhead.flask import FlaskUrlFor

This is a class that will lazily load the url_for function from Flask to ensure that when it comes to compile the Head it will be within context.

...
from pyhead import Head
from pyhead import elements as e
from pyhead.flask import FlaskUrlFor
...

@app.get("/my-cool-page")
def my_cool_page():
    head = Head(
        [
            ...,
            e.Stylesheet(FlaskUrlFor("static", filename="main.css")),
            ...,
        ]
    )
    return render_template("my_cool_page.html", head=head)

New

You can now define and store Heads in class style. This is nice if you'd like to keep all your Heads in one file and import them where you need them.

app/page_head.py

...
from pyhead import HeadClass
from pyhead import elements as e
...

class MyHead(HeadClass):
    elements = [
        e.Page(
            title="Hello World",
            description="This is a test",
            keywords="test, hello, world",
            subject="Hello World",
            rating="General",
        )
    ]

app/__init__.py

...
from app.page_head import MyHead
from pyhead import elements as e
...


@app.get("/my-cool-page")
def my_cool_page():
    return render_template("my_cool_page.html", head=MyHead())

5.2.1

30 Aug 18:31

Choose a tag to compare

Add all elements to __all__ in main package __init__.py - this allows from pyhead import Page and from pyhead.elements import Page

This was done as the IDE would automatically add the import as from pyhead import Page then show a warning about the element not being in __all__

5.2.0

04 Aug 18:52

Choose a tag to compare

When extending from a copy all the tags associated with the Page element are cleared if a new Page elements is passed in. This was to fix the issue that after extending, the description of the replaced Page element would still exist.

This is also the case for the SocialMediaCard element.

5.1.0

23 Jul 09:36

Choose a tag to compare

  • Bug fix - favicon cli generator key error when generating .py file
  • Remove unused function
  • Add .copy() method to allow for a new instance of Head to be created

5.0.0

18 Jul 15:03

Choose a tag to compare

Moved to a much more simplified way to work with adding elements.

from pyhead import Head
from pyhead.elements import Page

head = Head([
    Page(title="My Cool Website")
])

4.2.0

19 Nov 10:28

Choose a tag to compare

  • Added better lookup id generation on tags that use it.
  • Added push to top arg on some tags that may need to be above others (useful in JS)

4.1.0

13 Sep 11:08

Choose a tag to compare

  • pre-commit added to workflow
  • version and description moved to pyproject file

4.0.1

12 Sep 20:58

Choose a tag to compare

  • passing mypy
  • passing pyright
  • added set_stylesheet method
  • updated readme with new examples