Skip to main content

tagz is a html tags builder

Project description

Github Actions Coveralls Latest Version python wheel Python Versions license

tagz

tagz is an extremely simple library for building html documents without using templates, just with python code.

from tagz import html, Page


page = Page(
    lang="en",
    body_element=html.body(
        html.h1("Hello"),
        html.div(
            html.strong("world"),
        ),
        html.a(
            "example link",
            html.i("with italic text"),
            href="https://example.com/"
        ),
    ),
    head_elements=(
        html.meta(charset="utf-8"),
        html.meta(name="viewport", content="width=device-width, initial-scale=1"),
        html.title("tagz example page"),
        html.link(href="/static/css/bootstrap.min.css"),
        html.script(src="/static/js/bootstrap.bundle.min.js"),
        html.style(
            ".container, .container-fluid {transition:opacity 600ms ease-in;}"
        )
    ),
)

# `pretty=False` should be faster but performs not a human-readable result
print(page.to_html5(pretty=True))

writes something like this:

<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8"/>
		<meta name="viewport" content="width=device-width, initial-scale=1"/>
		<title>
			tagz example page
		</title>
		<link href="/static/css/bootstrap.min.css"/>
		<script src="/static/js/bootstrap.bundle.min.js">
		</script>
		<style>
			.container, .container-fluid {transition:opacity 600ms ease-in;}
		</style>
	</head>
	<body>
		<h1>
			Hello
		</h1>
		<div>
			<strong>
				world
			</strong>
		</div>
		<a href="https://example.com/">
			example link
			<i>
				with italic text
			</i>
		</a>
	</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

tagz-0.1.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

tagz-0.1.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file tagz-0.1.2.tar.gz.

File metadata

  • Download URL: tagz-0.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.2 Darwin/22.5.0

File hashes

Hashes for tagz-0.1.2.tar.gz
Algorithm Hash digest
SHA256 720a734195dc08febd5b91d640f734ee4bb5be7aea4874ec72bfc09af624f56a
MD5 2ec55068a104e72dd919f9bf2ddf7c84
BLAKE2b-256 df09a64df674571b80e216b9f62d21e79397a580187ab413e9bdb48f0829ad6f

See more details on using hashes here.

File details

Details for the file tagz-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tagz-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.2 Darwin/22.5.0

File hashes

Hashes for tagz-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e72787d95e7fe08fda8cc42dc5b111afe10ba84f7bce72b007d202200ec60084
MD5 0567f668f6361dbefa9da27fa4d850b3
BLAKE2b-256 0ba90fd3c4b052d8322a2ede5399a76c8bc96bff0414ab697534b5b4aff006f8

See more details on using hashes here.

Supported by

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