[![Upload Python Package](https://github.com/GrafLearnt/HTMLight/actions/workflows/python-publish.yml/badge.svg)](https://github.com/GrafLearnt/HTMLight/actions/workflows/python-publish.yml)
# Abstract
Light html generator
# Install
```bash
pip3 install htmlight
```
#### or
```bash
poetry add git+https://github.com/GrafLearnt/HTMLight.git
```
#### or
```bash
pip3 install git+https://github.com/GrafLearnt/HTMLight.git
```
## Disclaimer
Despite htmlight is able to generate full html page, it is designed to generate small fragments of code like:
```python
from htmlight import h
from flask_babel import lazy_gettext
from flask_login import current_user
TEMPLATE = h.div(h.hr(), h.span("{hello} {username}"), h.hr())
def get_html():
return TEMPLATE.format(hello=lazy_gettext("Hello"), username=current_user.name)
```
#### or
```python
from htmlight import h
from flask_babel import lazy_gettext
from flask_login import current_user
def get_html():
return h.div(h.hr(), h.span(lazy_gettext("Hello"), " ", current_user.name), h.hr()))
```
## Usage
### Code
```python
from htmlight import h
landing_page = h.html(
h.head(
h.title("Welcome to Our Website"),
h.link(attributes={"rel": "stylesheet", "href": "styles.css"}),
),
h.body(
h.header(
h.h1(
"Welcome to Our Website",
attributes={
"style": (
" color:"
" #333;"
" text-align:"
" center;"
" background-color:"
" #F0F0F0;"
" padding: 20px;"
)
},
),
h.p(
"Explore our amazing content", attributes={"style": "font-size: 20px; color: #555;"}
),
),
h.main(
h.h2("Featured Articles", attributes={"style": "color: #444; text-align: center;"}),
h.article(
h.h3("Article 1", attributes={"style": "color: #0072d6;"}),
h.p("This is the first article content", attributes={"style": "color: #666;"}),
),
h.article(
h.h3("Article 2", attributes={"style": "color: #00a86b;"}),
h.p("This is the second article content", attributes={"style": "color: #666;"}),
),
),
h.footer(
h.p(
"© 2023 Our Website",
attributes={
"style": (
"text-align: center;"
" background-color: #333;"
" color: #fff;"
" padding: 10px;"
" flex-shrink: 0;"
" background-color: #333;"
" position: absolute;"
" left: 0;"
" bottom: 0;"
" width: 100%;"
" overflow: hidden;"
)
},
),
),
),
attributes={
"style": "background-color: #f2f2f2; font-family: Arial, sans-serif;",
},
)
with open("landing_page.html", "w") as f:
f.write(landing_page)
```
### Result page
![Result](assets/example.png?raw=true )
Raw data
{
"_id": null,
"home_page": "https://github.com/GrafLearnt/htmlight",
"name": "htmlight",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "html",
"author": "Kostiantyn Shmyhelskyi",
"author_email": "graflearnt@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e2/e0/a99173681fb3f7984b8c59369e6fe915974d522c5bc442735006d7435e63/htmlight-0.1.1.tar.gz",
"platform": null,
"description": "[![Upload Python Package](https://github.com/GrafLearnt/HTMLight/actions/workflows/python-publish.yml/badge.svg)](https://github.com/GrafLearnt/HTMLight/actions/workflows/python-publish.yml)\n# Abstract\nLight html generator\n# Install\n```bash\npip3 install htmlight\n```\n#### or\n```bash\npoetry add git+https://github.com/GrafLearnt/HTMLight.git\n```\n#### or\n```bash\npip3 install git+https://github.com/GrafLearnt/HTMLight.git\n```\n\n## Disclaimer\nDespite htmlight is able to generate full html page, it is designed to generate small fragments of code like:\n\n```python\nfrom htmlight import h\nfrom flask_babel import lazy_gettext\nfrom flask_login import current_user\n\n\nTEMPLATE = h.div(h.hr(), h.span(\"{hello} {username}\"), h.hr())\n\n\ndef get_html():\n return TEMPLATE.format(hello=lazy_gettext(\"Hello\"), username=current_user.name)\n\n```\n#### or\n```python\nfrom htmlight import h\nfrom flask_babel import lazy_gettext\nfrom flask_login import current_user\n\n\ndef get_html():\n return h.div(h.hr(), h.span(lazy_gettext(\"Hello\"), \" \", current_user.name), h.hr()))\n```\n## Usage\n### Code\n```python\nfrom htmlight import h\n\n\nlanding_page = h.html(\n h.head(\n h.title(\"Welcome to Our Website\"),\n h.link(attributes={\"rel\": \"stylesheet\", \"href\": \"styles.css\"}),\n ),\n h.body(\n h.header(\n h.h1(\n \"Welcome to Our Website\",\n attributes={\n \"style\": (\n \" color:\"\n \" #333;\"\n \" text-align:\"\n \" center;\"\n \" background-color:\"\n \" #F0F0F0;\"\n \" padding: 20px;\"\n )\n },\n ),\n h.p(\n \"Explore our amazing content\", attributes={\"style\": \"font-size: 20px; color: #555;\"}\n ),\n ),\n h.main(\n h.h2(\"Featured Articles\", attributes={\"style\": \"color: #444; text-align: center;\"}),\n h.article(\n h.h3(\"Article 1\", attributes={\"style\": \"color: #0072d6;\"}),\n h.p(\"This is the first article content\", attributes={\"style\": \"color: #666;\"}),\n ),\n h.article(\n h.h3(\"Article 2\", attributes={\"style\": \"color: #00a86b;\"}),\n h.p(\"This is the second article content\", attributes={\"style\": \"color: #666;\"}),\n ),\n ),\n h.footer(\n h.p(\n \"\u00a9 2023 Our Website\",\n attributes={\n \"style\": (\n \"text-align: center;\"\n \" background-color: #333;\"\n \" color: #fff;\"\n \" padding: 10px;\"\n \" flex-shrink: 0;\"\n \" background-color: #333;\"\n \" position: absolute;\"\n \" left: 0;\"\n \" bottom: 0;\"\n \" width: 100%;\"\n \" overflow: hidden;\"\n )\n },\n ),\n ),\n ),\n attributes={\n \"style\": \"background-color: #f2f2f2; font-family: Arial, sans-serif;\",\n },\n)\n\nwith open(\"landing_page.html\", \"w\") as f:\n f.write(landing_page)\n```\n### Result page\n![Result](assets/example.png?raw=true )\n\n",
"bugtrack_url": null,
"license": "GNU General Public License v3.0",
"summary": "Light html generator",
"version": "0.1.1",
"project_urls": {
"Documentation": "https://github.com/GrafLearnt/htmlight/blob/main/README.md",
"Homepage": "https://github.com/GrafLearnt/htmlight"
},
"split_keywords": [
"html"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9d7b84367e91d363c43bca74bb34b72304001dc22dd7bd98eb0d1cff58feecc3",
"md5": "f44928fb6917f3bf0546f34f2b03c0c5",
"sha256": "0fb90fcb737bb6cc588bf362d8d36e170c6cbac72508ab965fb864d8f71b2667"
},
"downloads": -1,
"filename": "htmlight-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f44928fb6917f3bf0546f34f2b03c0c5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 14764,
"upload_time": "2024-10-06T19:10:28",
"upload_time_iso_8601": "2024-10-06T19:10:28.269451Z",
"url": "https://files.pythonhosted.org/packages/9d/7b/84367e91d363c43bca74bb34b72304001dc22dd7bd98eb0d1cff58feecc3/htmlight-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e2e0a99173681fb3f7984b8c59369e6fe915974d522c5bc442735006d7435e63",
"md5": "9ca3deb5318e5ebd39a0addd9af85eba",
"sha256": "bef7b8d2ef93abefce5af640b70ae32e701290082f4a6a78d00426a778c93bd7"
},
"downloads": -1,
"filename": "htmlight-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "9ca3deb5318e5ebd39a0addd9af85eba",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 14501,
"upload_time": "2024-10-06T19:10:29",
"upload_time_iso_8601": "2024-10-06T19:10:29.425799Z",
"url": "https://files.pythonhosted.org/packages/e2/e0/a99173681fb3f7984b8c59369e6fe915974d522c5bc442735006d7435e63/htmlight-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-06 19:10:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "GrafLearnt",
"github_project": "htmlight",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "htmlight"
}