HTML generator for Flask applications. Make your HTML code more readable and easier to maintain.
Project description
Flask-HTML
HTML generator for Flask applications. Make your HTML code more readable and easier to maintain.
Installation
pip install flask_html
Usage
from flask_html import Page, Head
from flask_html.core import Style
from flask_html.tags import Body, Div, P
from flask import request
@app.route('/')
def index():
head = Head('Title', [],['https://code.jquery.com/jquery-3.6.1.min.js'], [{"meta_property": "value"}])
page = Page(head)
page.register_js("""
$(document).ready(function(){
$("body").append("<p>hello world</p>");
})
""")
body = Body(page, styles=Style(color="red", padding_top="15px"),classes=['class1', 'class2'], id='body_id',elements=[
Div(styles=Style(margin="10px"), classes=['class1', 'class2'], id='div_id', elements=[
P(styles=Style(color="blue"), classes=['class1', 'class2'], id='p_id', elements=[
"Hello World"
])
])
])
return page.render(body, request)
Elements
Example of Div elements
"""Div HTML element
Args:
styles (Style, optional): Inline css styles. Defaults to None.
classes (List[str], optional): List of class names. Defaults to [].
id (str, optional): Unique ID. Defaults to None.
elements (List[object], optional): List of child elements. Defaults to [].
props (Dict[str, str], optional): Additional tag properties. Defaults to {}.
"""
Div(styles=None, classes=[], id=None, elements=[], props={})
To Do
- All HTML tags
- Inline CSS
- Classes
- ID
- Child elements
- Additional tag properties
- JS
- Meta tags
- Link tags
- Title
- Head
- Body
- Page
- Element event listeners
- DOM manipulation
- More examples
License
This project is licensed under the MIT License (see the LICENSE
file for details).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-HTML-1.1.1.tar.gz
(9.2 kB
view details)
Built Distribution
File details
Details for the file Flask-HTML-1.1.1.tar.gz
.
File metadata
- Download URL: Flask-HTML-1.1.1.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e6bef8ebe76202b5e20ac578de8f1c87037a00cb56ae5ff997de07593821ab8 |
|
MD5 | 11b6a14d2c5344d38e1239d552325c60 |
|
BLAKE2b-256 | 20bb4e04dbb20cef1f0697b3d7459acff564c1db960054bb3ca96f4f8659baf9 |
File details
Details for the file Flask_HTML-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: Flask_HTML-1.1.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20b0fe4877ec24f24479fb9feb2a83d19145e645231062cabc17e98802a515ee |
|
MD5 | f637e60618a0cd84fed137644e2fa7d7 |
|
BLAKE2b-256 | 4945ffbe26f776d8d781f1189fa0f85286bf7e64f88b05fe82b847e9db28523c |