WTForms companion library to provide polyglot HTML output
Project description
WTForms-Polyglot
WTForms companion library to provide polyglot HTML (i.e., XML-compatible) output.
Polyglot markup is a set of rules for how to write HTML. A document that uses
polyglot markup is both a valid HTML5 document as well as a well-formed XML
document, that can be served with either a text/html
or an
application/xhtml+xml
MIME type.
This package provides the PolyglotForm
class, which is built on top of
WTForms’ default Form
. When using PolyglotForm
, fields will be rendered
with polyglot markup. For example, given the following form:
from wtf_polyglot import PolyglotForm
from wtforms import BooleanField
class MyForm(PolyglotForm):
foo = BooleanField("foo", default=True)
Rendering MyForm.foo
will result in the following XML-compliant output:
<input checked="checked" id="foo" name="foo" type="checkbox" value="y" />
In contrast, using WTForms’ default Form
, the output would be:
<input checked id="foo" name="foo" type="checkbox" value="y">
In addition, this package provides a custom implementation of WTForms’
SubmitField
, which renders as a <button>
instead of an <input>
element.
For example:
from wtf_polyglot import PolyglotForm, SubmitField
class MyForm(PolyglotForm):
foo = SubmitField("Bar")
Produces this output:
<button id="foo" name="foo" type="submit" value="Bar">Bar</button>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wtforms_polyglot-0.4.0.tar.gz
.
File metadata
- Download URL: wtforms_polyglot-0.4.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.2 Linux/5.4.109+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1d98c2008212039ae416147638cfb8e758b55300494cd2838ecc87f9302b5da |
|
MD5 | 93e49cd915177fd7acfa8f6dc06cd997 |
|
BLAKE2b-256 | 7e297586eb78717324e3df366557e2f3237bfbd90359bdfc128c68086bcbc7fc |
File details
Details for the file wtforms_polyglot-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: wtforms_polyglot-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.2 Linux/5.4.109+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d2015f9b918dce7c649e4d64127877e0731d193af3769e4bbda5cbb346ad010 |
|
MD5 | 8ddaf426f7af67e7c350649f556b90fd |
|
BLAKE2b-256 | 582eda98e2fe6a65ea278044beffd98627adbe1b5712fee83ee0220b7de860c1 |