Metadata-Version: 2.1
Name: wtforms-polyglot
Version: 0.4.0
Summary: WTForms companion library to provide polyglot HTML output
Home-page: https://gitlab.com/obda/wtforms-polyglot
License: BSD-3-Clause
Author: Clemens Kaposi
Author-email: clemens@kaposi.name
Requires-Python: >=3.7,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: wtforms (>=3.0.1,<4.0.0)
Project-URL: Repository, https://gitlab.com/obda/wtforms-polyglot
Description-Content-Type: text/markdown

WTForms-Polyglot
================

WTForms companion library to provide [polyglot HTML][1] (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>

[1]: http://www.w3.org/TR/html-polyglot/

