Flask-Pure is an extension to Flask that helps integrate Pure.css to your Flask application.
- Installation
pip install Flask-Pure
- Configuration
from flask import Flask, render_template from flask_pure import Pure app = Flask(__name__) app.config['PURECSS_RESPONSIVE_GRIDS'] = True app.config['PURECSS_USE_CDN'] = True app.config['PURECSS_USE_MINIFIED'] = True Pure(app) @app.route('/') def hello(): return render_template('hello.html') if __name__ == '__main__': app.run(debug=True)
- In
templates/hello.html
:
{% extends "pure/layout.html" %} {% block title %}Hello world from flask-pure{% endblock %} {% block nav %} <div class="pure-menu pure-menu-horizontal"> <!-- ... --> </div> {% endblock %} {% block content %} <h1>Hello world</h1> {% endblock %}
- Profit!
Once registered, this extension provides a template variable called
pure
, it has a property named css
that will be rendered
as HTML <link>
tag to the Pure.css stylesheets either from free CDN or
be served from a bundled blueprint, also called pure
.
A {{ pure.css }}
inside <head>
tag is all you need.
A bare bone HTML5 template is also available as pure/layout.html
.
Please check out the example in code repository and documentation for details.
BSD New, see LICENSE for details.