Adds Coffeescript support to Flask applications.
Flask-Espresso will compile on the fly your coffee-scripts in the template directory of your application. To avoid performance issues, a cache mechanism retrieves the scripts already compiled.
pip install Flask-Espresso
How-to use it
A simple example to show you how to use it. Create a new Flask application and put a coffeescript file
script.coffee in its template directory.
from flask import Flask from flask.ext.espresso import Espresso, espresso app = Flask(__name__) esp = Espresso(app) @app.route("/") def hello(): return espresso('script.coffee') if __name__ == "__main__": app.run(debug=True)
The following config options are available :
ESPRESSO_DEFAULT_COMPILER: the full path to an alternate
coffe-script.jsin charge of the compilation of the scripts. If not set, Flask-Espresso will rely on the embedded version of coffee-script.
ESPRESSO_SPIDERMONKEY_ENCODING = 'latin1')
When calling the
espresso function, the following options are available :
force: Tell espresso to force the compilation of the file, despite having it in the cache. (default is
cache: Tell espresso to not cache the result of the compilation. (default is
minify: Tell espresso to minify the result of the compilation. (default is
The following example show you how to use them:
espresso('script.coffee', force=True, cache=False, minify=True)