Skip to main content

Bootstrap helper for Flask/Jinja2.

Project description

Bootstrap-Flask

Bootstrap 4 helper for Flask/Jinja2. Based on Flask-Bootstrap, but lighter and better.

Installation

$ pip install bootstrap-flask

Initialization

from flask_bootstrap import Bootstrap
from flask import Flask

app = Flask(__name__)

bootstrap = Bootstrap(app)

Resources helpers

When development, Bootstrap-Flask provides two helper functions that can be used to generate resources load code in template: bootstrap.load_css() and bootstrap.load_js()

Call it at your template, for example:

<head>
{{ bootstrap.load_css() }}
</head>
<body>
...
{{ bootstrap.load_js() }}
</body>

Macros

Macro Templates Path Description
render_field() bootstrap/form.html Redner a WTForms form field
render_form() bootstrap/form.html Render a WTForms form
render_pager() bootstrap/pagination.html Render a basic pagination, only include previous and next button.
render_pagination() bootstrap/pagination.html Render a standard pagination
render_nav_item() bootstrap/nav.html Render a navigation item
render_breadcrumb_item() bootstrap/nav.html Render a breadcrumb item
render_static() bootstrap/utils.html Render a resource reference code (i.e. <link>, <script>)

How to use these macors? It's quite simple, just import them from the correspond path and then call them like any other macro:

{% from 'bootstrap/form.html' import render_form %}

{{ render_form(form) }}

API documentation will coming soon...

Run the demo application

$ git clone https://github.com/greyli/bootstrap-flask.git
$ pip install flask flask-wtf flask-sqlalchemy bootstrap-flask
$ cd bootstrap-flask/examples
$ flask run

Now go to http://localhost:5000.

Changelog

1.0.2

Release date: 2018/7/16

  • Include popper.js before bootstrap.js in bootstrap.load_js(). (#2)

1.0.1

Release date: 2018/7/1

  • Fix local resources path error
  • Add basic unit tests

1.0

Release date: 2018/6/11

Initialize release.

License

This project is licensed under the MIT License (see the LICENSE file for details).

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

Bootstrap-Flask-1.0.2.tar.gz (750.7 kB view details)

Uploaded Source

Built Distribution

Bootstrap_Flask-1.0.2-py2.py3-none-any.whl (767.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file Bootstrap-Flask-1.0.2.tar.gz.

File metadata

File hashes

Hashes for Bootstrap-Flask-1.0.2.tar.gz
Algorithm Hash digest
SHA256 22955c529eeecf9848942dbb44ba5da3ab54e30385e651634c714e6fcbaea50d
MD5 3b26e0208a72a00293bd9a74aa415101
BLAKE2b-256 7e2ebb14ab4c8bb2222e7cdc661b86936faec1527a458390ef2649bd3a54d860

See more details on using hashes here.

File details

Details for the file Bootstrap_Flask-1.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for Bootstrap_Flask-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 32dfb93ea7c7ab78c0a566785f8366c0ccbd313c1972d8cf84cc285c97f5454e
MD5 e4c96224c0b9604a3771ccc7a08be62c
BLAKE2b-256 669548100b3237eabc9ea867bb52a47e17a24b56e73a0434cc99662275dbb809

See more details on using hashes here.

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