Skip to main content

Parse Markdown form and generate serializable FlaskForm

Project description

Latest Version License Python Versions CI Coverage

flask-mdform

An extension for Flask to generate Flask-WTF parsing Markdown based document using mdforms. Checkout the syntax in the mdform page.

Installation

pip install flask-mdform

Usage

Use it like this to create a WTForm compatible template:

or use it like this to create a WTForm compatible template that uses Bootstrap4.

>>> from flask_mdform import Markdown, FormExtension, flask_wtf_bs4
>>> md = Markdown(extensions = [FormExtension(formatter=flask_wtf_bs4("jQuery", "wtf."))])
>>> html = md.convert(text)  # this is the jinja template with Flask WTForm and BS4
>>> form_dict = md.Form      # this is the definition dict

Here, the two arguments in the formatter can be use it to customize it. “jQuery” is the name of the jQuery variable, “wtf.” is the prefix where WTForm bootstrap form_field function is located.

Other functions

use_mdform: decorator to be used in a flask route to parse, display, load and store form and its values.

form_to_dict: iterates through a filled form and returns a dictionary with the values in a json compatible format.

dict_to_formdict: iterates through a dict, parsing each value using the spec defined in form_cls.

from_mdfile: generates form metadata, template, form from markdown file.

from_mdstr: generates form metadata, template, form from markdown string.

See AUTHORS for a list of the maintainers.

To review an ordered list of notable changes for each version of a project, see CHANGES

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

Flask-mdform-0.1.1.tar.gz (16.5 kB view hashes)

Uploaded Source

Built Distribution

Flask_mdform-0.1.1-py2.py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page