Skip to main content

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 selectors

html.at("body").div("prompt-msg", "popup").done()
html.at("#prompt-msg").div(Class="header").text("Welcome!").done()
html.at("#prompt-msg").div(Class="message").text("Lorem ipsum...").done()

# CSS as a string
html.css(".header", "font-size: 14px; font-weight: bold;")

# CSS as a dictionary
design = { "font-size": "12px",
           "color": "#222",
           "background-color": "#f0f0f0" }
html.css(".message", design)
html.css(".message", { "font-size": "12px",
                       "color": "#222",
                       "background-color": "#f0f0f0" })

CSS fonts

html.font("funfont", "funfont.ttf")
html.at("body").div(Class="fun").text("Fun message...").done()
    html.css(".fun", "font-family: funfont;")

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wbuilder-2.0.7.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wbuilder-2.0.7-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file wbuilder-2.0.7.tar.gz.

File metadata

  • Download URL: wbuilder-2.0.7.tar.gz
  • Upload date:
  • Size: 9.6 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

Hashes for wbuilder-2.0.7.tar.gz
Algorithm Hash digest
SHA256 295ec7f6065ee8478d034fdd063ca76b323d44c6187da344b1ab36bbf2a7400f
MD5 d9f084323ce3c1f59eefb3e62d468ccf
BLAKE2b-256 17606639945114af569391c2b1f2f33fb64bcff8baca7d7934b1a766584c2d86

See more details on using hashes here.

File details

Details for the file wbuilder-2.0.7-py3-none-any.whl.

File metadata

  • Download URL: wbuilder-2.0.7-py3-none-any.whl
  • Upload date:
  • Size: 9.2 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

Hashes for wbuilder-2.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9b7c8326ca6abc1ac3103498b4504e74765b5a7acdf61df696eb77caf5fa75e3
MD5 a501d245153ce91498ba07100d8507ca
BLAKE2b-256 5c29665d26d22c3ea8020af5df7405298f0b1434fa3d11a855dc6eb07911e0e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page