Library for generating HTML or XML in a pythonic way. Can fill HTML forms with default values and errors. Pure python alternative to html templating languages.
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.1.zip
(10.6 kB
view details)
yattag-0.9.1.tar.gz
(8.2 kB
view details)
File details
Details for the file yattag-0.9.1.zip.
File metadata
- Download URL: yattag-0.9.1.zip
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f35056d384acaa58dc3371c36a99f4c060e1484aae56feae6713d94eeef9b40d
|
|
| MD5 |
44b6028803ce69424648b04b52211f71
|
|
| BLAKE2b-256 |
6af0d506dcba2c2c171d80704ef48c89a934a20dba6b33120a9ce352ebe65934
|
File details
Details for the file yattag-0.9.1.tar.gz.
File metadata
- Download URL: yattag-0.9.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50018be3b80f38a01caee439527a13a807031ac0cf53f1fc98b8c1e1394af14b
|
|
| MD5 |
77ecb4fa5b322f81c677dcc9cd0f472b
|
|
| BLAKE2b-256 |
9f132ed29ecf8d3594fd8d9d67ec3e0deefa42401c07bb72ea0dcbb657d76a21
|