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
GitHub repo: https://github.com/leforestier/yattag
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.6.zip
(11.2 kB
view details)
yattag-0.9.6.tar.gz
(8.9 kB
view details)
File details
Details for the file yattag-0.9.6.zip.
File metadata
- Download URL: yattag-0.9.6.zip
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aa288a41f6fe53a1380a89ded8aa779681ac13977207b155ec6d2903528f22a
|
|
| MD5 |
173cb13e6a169ad22d051bdfcf4171e2
|
|
| BLAKE2b-256 |
b8cff225ede90ee5e4e6475a58da4bda7d1374f6e554e1fe57285d6f8211c2d7
|
File details
Details for the file yattag-0.9.6.tar.gz.
File metadata
- Download URL: yattag-0.9.6.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0770f72b5b7fa23bf3a635aebf352480695ca399e000171f806bc53b5648dbf
|
|
| MD5 |
862619fa2d87168bbe623c95e4663b70
|
|
| BLAKE2b-256 |
26aaf898db326b15d538656e988eb050c0589d4e2b5f999344b86667bb1e2563
|