Skip to main content

tagz is a html tags builder

Project description

tagz

[Github Actions](https://github. com/mosquito/tagz/actions?query=branch%3Amaster) [Coveralls](https://coveralls. io/github/mosquito/tagz?branch=master) Latest Version python wheel Python Versions license

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.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tagz-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 029519278ca1afb61acbc770f2c43f47dc855d770bd32cc6b45f645964e85020
MD5 4626dee3194fcd9f9b9128a9ddfc0e17
BLAKE2b-256 535aa8e91af225a0f870ebe243fe30363975337998414153bf34943462f41ffe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tagz-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cad3ed87111ae3360aeb2d0a8f7559f6890e45b39d0b5079cb4984aa03b42d51
MD5 c9cb459d4b8cac207572354616903430
BLAKE2b-256 9d9d945212f384ea6392c826026159c7a50ee36fb089339becf43647b5e117fc

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