Skip to main content

A package for generating HTML and CSS

Project description

Domgen

Domgen is a library which can be used to generate minified HTML, with rich custom component support and material design components as standard.

To make a basic page's HTML code:

import dom

page_model = dom.HTML(
    dom.Head(
        dom.Title("My Glorious Test Page"),
        dom.ExternalResourceLink(rel="stylesheet", href="assets/style.css")
    ),
    dom.Body(
        dom.ContentDivision(classes={"red", "centre"})(
            "My red and centred content with",
            dom.Button(onclick="alert('hello user')")(
                "a button"
            ),
            "in it",
        )
    )
)
page_code = page_model.serialise()
page_code_readable = page_model.serialise(minify=False)
<!-- page_code -->
<!DOCTYPE html><html><head><title>My Glorious Test Page</title><link rel="stylesheet" href="assets/style.css" /></head><body><div class="red centre">My red and centred content with<button onclick="alert('hello user')">a button</button>in it</div></body></html>
<!-- page_code_readable -->
<!DOCTYPE html>
<html>
    <head>
        <title>
            My Glorious Test Page
        </title>
        <link rel="stylesheet" href="assets/style.css" />
    </head>
    <body>
        <div class="red centre">
            My red and centred content with
            <button onclick="alert('hello user')">
                a button
            </button>
            in it
        </div>
    </body>
</html>

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

domgen-0.2.0a0.tar.gz (21.3 kB view details)

Uploaded Source

File details

Details for the file domgen-0.2.0a0.tar.gz.

File metadata

  • Download URL: domgen-0.2.0a0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

File hashes

Hashes for domgen-0.2.0a0.tar.gz
Algorithm Hash digest
SHA256 fdfff675c94d04f1890f51b3cd0fbff1d1391476922d60446bc0bd2f9f5c51da
MD5 92cc4a106763171a740bfdb2b430b586
BLAKE2b-256 c136eb4a8e2602494447ebe1b45e4a311248e82867572ae5d62e76d0d3c7321b

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