librelist archives

« back to archive

New extension: static resource management with Flask-Fanstatic

New extension: static resource management with Flask-Fanstatic

Matt Good
2012-11-19 @ 23:04
I've posted the first release of a Flask extension to integrate with the 
Fanstatic resource publishing package:

Fanstatic lets you Pythonically package and use static resources like CSS 
and JavaScript.  For example, you can install the Fanstatic jQuery package
with pip:

  pip install js.jquery

And in your code you would tell Fanstatic to use it:

  from js.jquery import jquery

This extension adds integrations for Flask to enable features like easily 
declaring the resources you need from a template like:

  {{ g.fanstatic.needs('js.bootstrap:bootstrap') }}

With that one line, Fanstatic will include Bootstrap's CSS, JavaScript, 
and jQuery (a dependency) automatically.

The extension also makes it easy to declare static resources from your 
Flask application, which can include dependencies on other resources 
either within your app, or in other packages.

This extension is brand-new so there might be some rough edges, but I'd be
interested in your feedback.

See the Fanstatic documentation for more info about the other capabilities
of Fanstatic: