HTML template generator for Python.
Project description
wBuilder
wBuilder
(c) 2020 Rodney Maniego Jr.
MIT License
HTML template generator for Python.
Read: Introducing wBuilder: An HTML5 Generator for Python
Requirements:
- Arkivist, BS4, Namari
Future Features
- Simple JQuery generator
WebBuilder Usage
Import
from wbuilder import WebBuilder
Initialize
html = WebBuilder()
html = WebBuilder("web.html")
html = WebBuilder(html="<span id='label'></span>")
HTML head
html.prop("html", "lang", "en")
html.at("head").append("title", text="WebBuilder")
html.at("head").append("meta", charset="UTF-8")
html.at("head").append("meta", name="viewport", content="width=device-width, initial-scale=1, shrink-to-fit=no")
html.at("head").append("link", rel="icon", href="icon.png", type_="image/png", sizes="96x96", static=True)
html.at("head").append("link", rel="stylesheet", href="reset.css", static=True)
html.at("head").append("link", rel="stylesheet", href="design.css")
Basic usage
html.at("body").append("div", id="#popup .popup")
html.at("#popup").append("header3", id=".header", text="Welcome!")
CSS selectors
html.at("#popup").append("span", id="#popup-txt .popup-txt", text="Hello, user!")
html.at("#popup").append("button", id="#ok .blue", text="OK")
# CSS as a string
html.inlineCss("div", {"color": "#000"})
html.inlineCss("div", "font-size:12px;", reset=True))
# CSS as a dictionary
design = { "font-size": "12px", "color": "#222", "background-color": "#f0f0f0" }
html.at("#popup").append("div", id=".message", text="Lorem ipsum...", style=design)
Update element properties
html.prop("html", "lang", "en")
html.prop("#popup", "data-name", "container")
html.prop("#popup", "data-title", "message")
html.prop("div", "style", "font-size:12px;")
Preview HTML
content = html.build()
print(content)
Save to HTML file
html.save()
html.save("saveAsNewFile.html")
Save to/Read from JSON file
html.toJson("test.json")
html.fromJson("test.json")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wbuilder-3.0.4.tar.gz
(11.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wbuilder-3.0.4.tar.gz.
File metadata
- Download URL: wbuilder-3.0.4.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
119ceac6937dfbdac94e35236c2169460e6e692a430bd6ad898d61d3bb73beb8
|
|
| MD5 |
81951f62788ba02c6f5e70085b5eb86e
|
|
| BLAKE2b-256 |
548d8f488f96a19d77be80e8f89389a994ff42745a90f6e0234f10baba718be2
|
File details
Details for the file wbuilder-3.0.4-py3-none-any.whl.
File metadata
- Download URL: wbuilder-3.0.4-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5381f56325e1c6c997f307647391997b0ad5bfec2f0edc465bce0b81f5178364
|
|
| MD5 |
65e7da4d39a915ee45013c8b280a4c96
|
|
| BLAKE2b-256 |
ddb2d83761078b2ec4e0eed20d9d79c58d75ac0a8ec76731da3ce20061e83e4a
|