From c2bee8453e48c5afc1b310cf22f6ef253c5563a7 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Sat, 16 Mar 2024 08:16:13 +0530 Subject: [PATCH 1/2] feat: support for including CSS and JS separately --- ph7/context.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ph7/context.py b/ph7/context.py index bbca5ae..d3deca8 100644 --- a/ph7/context.py +++ b/ph7/context.py @@ -156,6 +156,26 @@ def _include_js(self, view: str) -> t.Any: for module in self.views["js"][view] ) + def include_js(self, context: t.Dict) -> t.Any: + """Include js files.""" + from ph7.html import unpack # pylint: disable=import-outside-toplevel + + view = context["_view"] + if view not in self.views["css"] and view not in self.cache["js"]: + return unpack() + + return self._include_js(view=view) + + def include_css(self, context: t.Dict) -> t.Any: + """Include css files.""" + from ph7.html import unpack # pylint: disable=import-outside-toplevel + + view = context["_view"] + if view not in self.views["css"] and view not in self.cache["js"]: + return unpack() + + return self._include_css(view=view) + def include(self, context: t.Dict) -> t.Any: """Include static files.""" from ph7.html import unpack # pylint: disable=import-outside-toplevel From 23814b3f9762931c37767ec76579abd7199f704c Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Sat, 16 Mar 2024 08:18:40 +0530 Subject: [PATCH 2/2] feat: bump to v0.1.0-rc5 --- README.md | 2 +- docs/{CHANGELOG => CHANGELOG.md} | 4 ++++ setup.py | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) rename docs/{CHANGELOG => CHANGELOG.md} (90%) diff --git a/README.md b/README.md index 3d70182..a72427e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

💧 PH7

- Python native HTML rendering + Python native HTML templates
## Why PH7? diff --git a/docs/CHANGELOG b/docs/CHANGELOG.md similarity index 90% rename from docs/CHANGELOG rename to docs/CHANGELOG.md index bdc2994..513d74f 100644 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.1.0-rc5 (16-03-2024) + +* Adds support for including CSS and JS files in separate blocks + # v0.1.0-rc4 (15-03-2024) * Adds template engine for Flask diff --git a/setup.py b/setup.py index b5011d3..99cd4e2 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,8 @@ long_description = (here / "README.md").read_text(encoding="utf-8") setup( name="ph7", - version="0.1.0-rc4", - description="Python native HTML rendering", + version="0.1.0-rc5", + description="Python native web templates", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/angrybayblade/ph7", @@ -37,7 +37,7 @@ }, project_urls={ "Documentation": "http://ph7.angrybayblade.me", - "Changelog": "https://github.com/angrybayblade/ph7/blob/main/docs/CHANGELOG", + "Changelog": "https://github.com/angrybayblade/ph7/blob/main/docs/CHANGELOG.md", "Issue Tracker": "https://github.com/angrybayblade/ph7/issues", }, )