Releases: CheeseCake87/pyhead
5.3.1
5.3.0
- Small adjustments were done to how some elements compile
- New type added to allow for the new functionality of
FlaskUrlForclass
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
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
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
- Bug fix - favicon cli generator key error when generating .py file
- Remove unused function
- Add
.copy()method to allow for a new instance ofHeadto be created
5.0.0
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
- 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
- pre-commit added to workflow
- version and description moved to pyproject file
4.0.1
- passing mypy
- passing pyright
- added set_stylesheet method
- updated readme with new examples