![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
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.
.. image:: https://travis-ci.org/leforestier/yattag.svg :target: https://travis-ci.org/leforestier/yattag
Why use a template engine when you can generate HTML or XML documents with Python in a very readable way?
( full tutorial on yattag.org_ )
Nested html tags, no need to close tags.
.. code:: python
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())
Yattag can fill your HTML forms with default values and error messages.
Pass a defaults
dictionary of default values, and an errors
dictionary of error messages to the Doc
constructor.
Then, use the special input
, textarea
, select
, option
methods when generating your documents.
Example with default values
.. code:: python
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())
Example with default values and errors
.. code:: python
from yattag import Doc
doc, tag, text = Doc(
defaults = {
'title': 'Untitled',
'contact_message': 'You just won the lottery!'
},
errors = {
'contact_message': 'Your message looks like spam.'
}
).tagtext()
with tag('h1'):
text('Contact form')
with tag('form', action = ""):
doc.input(name = 'title', type = 'text')
with doc.textarea(name = 'contact_message'):
pass
doc.stag('input', type = 'submit', value = 'Send my message')
print(doc.getvalue())
Full tutorial on yattag.org_
GitHub repo: https://github.com/leforestier/yattag
.. _yattag.org: https://www.yattag.org
FAQs
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.
We found that yattag demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.