Flask-Pure - a Flask extension for Pure.css

Flask-Pure is an extension to Flask that helps integrate Pure.css to your Flask application.

Quick Start

  1. Installation
pip install Flask-Pure
  1. Configuration
from flask import Flask, render_template
from flask.ext.pure import Pure

app = Flask(__name__)
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)
  1. 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 %}
  1. Profit!

License

BSD New, see LICENSE for details.

Configuration

Option Description
PURECSS_USE_CDN If True, css files will be served from CDN. If False, local copies of css files will be served. Default value is True.
PURECSS_USE_MINIFIED If True, the minified version of css files will be used. Default value is True

Template

In addition to provide Pure.css static assets, Flask-Pure comes with HTML5 template located in pure/layout.html for layout.

Predefined Blocks Purpose
html_attribs <html>‘s attributes
head all content inside <head> and </head>
meta for all <meta> tags
title content inside <title> and </title>
style links to css stylesheets
body_attribs <body>‘s attributes
body all content inside <body> and </body>
nav navigation links
content main content
script embedded javascript

API

Flask-Pure - a Flask extension for Pure.css

context processor to generate css link as purecss_stylesheets

class flask_pure.Pure(app=None)[source]

Flask-Pure extension

provides base template layout as pure/layout.html and links to the Pure.css static assets.

init_app(app)[source]

create and register a blueprint with the Flask application.

Parameters:app – Flask application instance