Bootstrap 4 & 5 helper for your Flask projects.
Bootstrap-Flask is a collection of Jinja macros designed to work with Bootstrap 4 & 5 and Flask, facilitating the rendering of Flask-related data and objects to Bootstrap markup HTML. It simplifies tasks such as rendering Flask-WTF/WTForms form objects to Bootstrap forms, data objects to Bootstrap tables, and Flask-SQLAlchemy Pagination objects to Bootstrap pagination. The extension streamlines the integration of Flask and Bootstrap elements, providing a more efficient development experience.
To install Bootstrap-Flask, you can register the extension in your Flask application and utilize the provided macros. Here is an example of how to integrate the extension:
from flask import Flask
from flask_wtf import FlaskForm
from bootstrap_flask import Bootstrap
from wtforms import StringField, SubmitField
app = Flask(__name__)
# Register the Bootstrap extension
bootstrap = Bootstrap(app)
# Define a sample Flask-WTF form
class SampleForm(FlaskForm):
name = StringField('Name')
submit = SubmitField('Submit')
Now you can use the render_form
macro in your template to render the form effortlessly:
{{/* render_form(form) */}}
For more installation details and usage examples, refer to the documentation.
Bootstrap-Flask is a valuable collection of Jinja macros designed to enhance the integration between Flask and Bootstrap, making the rendering of Flask-related data and objects to Bootstrap markup HTML more straightforward. Through its features such as rendering Flask-WTF/WTForms form objects, data objects, and Flask-SQLAlchemy Pagination objects to Bootstrap elements, Bootstrap-Flask streamlines the development process by providing a convenient way to work with Flask and Bootstrap together. It offers support for both Bootstrap 4 and 5, with clear migration paths and detailed documentation available for developers.