Skip to main content

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

Metadata

Release files for yattag 0.9.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for yattag 0.9.6
File Size Uploaded Provenance Actions
yattag-0.9.6.zip 11.2 kB Without provenance Details for yattag-0.9.6.zip
yattag-0.9.6.tar.gz 8.9 kB Without provenance Details for yattag-0.9.6.tar.gz

Release files / yattag-0.9.6.zip

Download URL yattag-0.9.6.zip
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1aa288a41f6fe53a1380a89ded8aa779681ac13977207b155ec6d2903528f22a
BLAKE2b-256 checksum
How to use checksums
b8cff225ede90ee5e4e6475a58da4bda7d1374f6e554e1fe57285d6f8211c2d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / yattag-0.9.6.tar.gz

Download URL yattag-0.9.6.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b0770f72b5b7fa23bf3a635aebf352480695ca399e000171f806bc53b5648dbf
BLAKE2b-256 checksum
How to use checksums
26aaf898db326b15d538656e988eb050c0589d4e2b5f999344b86667bb1e2563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for yattag 0.9.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.6 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page