tgext.coffeescript is based on tgext.scss by Alessandro Molina and is under the same license (MIT).
tgext.coffeescript can be installed both from pypi or from bitbucket:
You will also need to install the CoffeeScript compiler, for instructions on this check their website.
Using tgext.coffeescript is really simple, you edit your config/middeware.py and just after the #Wrap your base TurboGears 2 application with custom middleware here comment wrap app with CoffeeScriptMiddleware:
from tgext.coffeescript import CoffeeScriptMiddleware make_base_app = base_config.setup_tg_wsgi_app(load_environment) def make_app(global_conf, full_stack=True, **app_conf): app = make_base_app(global_conf, full_stack=True, **app_conf) # Wrap your base TurboGears 2 application with custom middleware here app = CoffeeScriptMiddleware(app) return app
app = CoffeeScriptMiddleware(app, minify=True)
You can change the cache backend storage into any dict like object that can serialize a dict object, for example, you can use beaker cache by passing the cache object to the middleware constructor:
from tgext.coffeescript import CoffeeScriptMiddleware from tg import cache
make_base_app = base_config.setup_tg_wsgi_app(load_environment)
app = CoffeeScriptMiddleware(app, bare=False)
This will disable the bare options for all files served with tgext.coffeescript, more granular control of this option may be available later depending on the need for it.