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:
- BS4
Go to examples/*.py for basic usage.
Returned value is in string and can be saved into file.
Future Features
- Basic JQuery generator
WebBuilder Usage
Import
from wbuilder.wbuilder import WebBuilder
Initialize
html = WebBuilder()
Basic usage
html.at("body").button()text("OK").done()
HTML head
html.at("head").title().text("WebBuilder").done()
html.at("head").meta().charset("UTF-8").done()
html.at("head").meta().name("viewport").content("width=device-width, initial-scale=1, shrink-to-fit=no").done()
# html.at("head").link().rel("icon").href("icon.png").Type("image/png").sizes("96x96").done(static=True)
# html.at("head").link().rel("stylesheet").href("reset.css").done(static=True)
html.at("head").link().rel("stylesheet").href("design.css").done()
CSS options
# No CSS
html.at("body").div("prompt-msg", "popup").done()
# CSS as a string
html.at("#prompt-msg").div(Class="header").text("Welcome!").css(".header", "font-size: 14px; font-weight: bold;").done()
# CSS as a dictionary
design = { "font-size": "12px",
"color": "#222",
"background-color": "#f0f0f0" }
html.at("#prompt-msg").div(Class="message").text("Lorem ipsum...").css(".message", design).done()
Preview HTML
print(html.build())
Save to file
# defaults
html.save_to_html()
html.save_stylesheet()
# custom filepaths
html.save_to_html("templates", "home.html")
html.save_stylesheet("static", "custom.css")
Css class
Initialize
from wbuilder.wbuilder import Css
print("\n# Initialize...")
css = Css(sort=True)
Show all selectors
print("\n# Bulk add dfrom string...")
css.add_from_string(".box", "width: 200px; height: 100px")
Show all selectors
print("\n# Bulk add dictionary...")
css.add(".btn", { "font-size": "16px",
"background-color": "#f0f0f0",
"color": "#c0c0c0"})
Show all selectors
print("\n# Add by property...")
css.update("body", "font-size", "12px")
css.update(".nav", "position", "fixed")
css.update(".nav", "font-size", "14px")
Show all selectors
print("\n# Show all selectors...")
print(css.build())
Save to file
print("\n# Save to file...")
css.save("static", "design.css")
Remove selector data
print("\n# Remove selector data..")
css.remove(".nav")
print(css.build())
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
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-2.0.0.tar.gz.
File metadata
- Download URL: wbuilder-2.0.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48c2246ae66da14844da16706e7afc8a4d64348e4164652432cf79a24f4bc470
|
|
| MD5 |
38cdfb9c95577058de0648d52e7ddb98
|
|
| BLAKE2b-256 |
82e9e8f93fb30f0c329828ab7b97c393fe4414392786aa87af0a37b2e790c972
|
File details
Details for the file wbuilder-2.0.0-py3-none-any.whl.
File metadata
- Download URL: wbuilder-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4fcbe1fcb3a5a3eabeeff45ad09ad19190238c0b60be0c281656720386e8a07
|
|
| MD5 |
18b0ff1724a68600dcd46e2b935c1755
|
|
| BLAKE2b-256 |
ac996116cefa99a0e0c9f2ee1ce22edcc85152a31ebc1d7bba209f78528a3afe
|