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

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.2.zip (10.6 kB view details)

Uploaded Source

yattag-0.9.2.tar.gz (8.3 kB view details)

Uploaded Source

File details

Details for the file yattag-0.9.2.zip.

File metadata

  • Download URL: yattag-0.9.2.zip
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yattag-0.9.2.zip
Algorithm Hash digest
SHA256 a0ef444ef81127e0767d5176724f642411dc9436a145908e0b6527573ed95b52
MD5 08d7a8f49fc977c0ac78f5709099591b
BLAKE2b-256 4fd1aace49a7ddea63bcfb0375a0c5e6555d5e939618e945e4d86db9550f9fd4

See more details on using hashes here.

File details

Details for the file yattag-0.9.2.tar.gz.

File metadata

  • Download URL: yattag-0.9.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yattag-0.9.2.tar.gz
Algorithm Hash digest
SHA256 27512a9b60550405594360318e658e3c24c2d244dea771ba2f1ebe4a199bac37
MD5 007bb250ebca513fcc7dc665f58580ee
BLAKE2b-256 7995d5bcc5d7df2916fd1d228de2e03e14279495659f96b3c996b98aa782fc90

See more details on using hashes here.

Release history Release notifications | RSS feed

1.16.1

1 file

1.16.0

1 file

1.15.2

1 file

1.15.1

1 file

1.15.0

1 file

1.14.0

1 file

1.13.2

1 file

1.13.1

1 file

1.13.0

1 file

1.12.2

1 file

1.12.1

1 file

1.12.0

1 file

1.11.2

1 file

1.11.1

1 file

1.11.0

1 file

1.10.1

1 file

1.10.0

1 file

1.9.2

1 file

1.9.1

1 file

1.9.0

1 file

1.8.0

1 file

1.7.2

2 files

1.7.1

2 files

1.7.0

2 files

1.6.0

2 files

1.5.3

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.1.0

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.9.6

2 files

0.9.5

2 files

0.9.4

2 files

0.9.3

2 files

This release

0.9.2 This release

2 files

0.9.1

2 files

0.9.0

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

1 file

0.8.0

1 file

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