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.8.4.zip
(8.5 kB
view details)
yattag-0.8.4.tar.gz
(6.2 kB
view details)
File details
Details for the file yattag-0.8.4.zip.
File metadata
- Download URL: yattag-0.8.4.zip
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43568fdf59d2973f7b6c2ddd533a829dae62263fc623a201e4619fb04a732eba
|
|
| MD5 |
014d73bc6f92dbaa049556a2a77f1fb4
|
|
| BLAKE2b-256 |
ac56d7a4a3f398e6f873d2eaf8eddc31e671eb99c71841bfe20614cbfd93eff8
|
File details
Details for the file yattag-0.8.4.tar.gz.
File metadata
- Download URL: yattag-0.8.4.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2a173a2c291c887d8d25c4d0015da251fb03d679e8cf71793dfec7156dcdd71
|
|
| MD5 |
e1432068f6573b41a0623e9ec25eb6ff
|
|
| BLAKE2b-256 |
d31cc251cc59330851b25626d5ce16749589f0e35674c77e7ac33f836afd9d29
|