Generate HTML or XML in a pythonic way. Pure python alternative to web template engines.Can fill HTML forms with default values and error messages.
Project description
Some examples:
( full tutorial on yattag.org )
Basic example
Nested html tags, no need to close tags.
from yattag import Doc
doc, tag, text = Doc().tagtext()
with tag('html'):
with tag('body', id = 'hello'):
with tag('h1'):
text('Hello world!')
print(doc.getvalue())
Html form rendering example with default values
from yattag import Doc
doc, tag, text = Doc(
defaults = {'ingredient': ['chocolate', 'coffee']}
).tagtext()
with tag('form', action = ""):
with tag('label'):
text("Select one or more ingredients")
with doc.select(name = 'ingredient', multiple = "multiple"):
for value, description in (
("chocolate", "Dark chocolate"),
("almonds", "Roasted almonds"),
("honey", "Acacia honey"),
("coffee", "Ethiopian coffee")
):
with doc.option(value = value):
text(description)
doc.stag('input', type = "submit", value = "Validate")
print(doc.getvalue())
Full tutorial on yattag.org
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 Distributions
yattag-0.9.3.zip
(11.2 kB
view details)
yattag-0.9.3.tar.gz
(8.9 kB
view details)
File details
Details for the file yattag-0.9.3.zip.
File metadata
- Download URL: yattag-0.9.3.zip
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b0e667913a4ca2ef6edaa6287e20e5d7eda8b15905b3fb95eb02f6bcaab8f55
|
|
| MD5 |
3a49057ec18fa09f4438e9c22b4b006d
|
|
| BLAKE2b-256 |
745da68a228b9526a90cfda10f1a1d9ff6ce73657a355e00f655e7fb0e3f95fa
|
File details
Details for the file yattag-0.9.3.tar.gz.
File metadata
- Download URL: yattag-0.9.3.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
117287aca2b37339c1b824147596ebf1a7e48536ce7ad00b2d056e3b7c2c58f1
|
|
| MD5 |
837ead9558205db2838bcb440efa92f7
|
|
| BLAKE2b-256 |
1fb6efd1ef6ff75c4bd99d0b379932dbc52f5f5e80c3b16401366163cf5de55f
|