Author: | Pedro Algarvio <ufs_REMOVE@ME_ufsoft.org> |
---|---|
Maintainer: | Domen Kozar <domen_REMOVE@ME_dev.si> |
Version: | 0.3.6 |
Source: | bitbucket.org |
Bug tracker: | bitbucket.org/issues |
Consider the MinificationWebHelpers an extension to WebHelpers.
Basicaly MinificationWebHelpers adds following options to the WebHelpers javascript_link and stylesheet_link functions:
For complete list of additional parameters reffer to base_link().
Note
Running Pylons/TG application in debug mode will force minfied and combined options off.
Note
For an up-to-date read of the documentation, always reffer to offical documentation page on site.
MinificationWebHelpers cache your javascript and css files through Beaker‘s @beaker.cache decorator. Default parameters passed to beaker cache:
beaker_kwargs = dict(key='sources', expire='never', type='memory')
Javascript minification is achieved through Python port of jsmin.
MinificationWebHelpers maps HTTP URLs to filesystem path by exaiming pylons config for static_files.
On your own Pylons application, inside <app>/lib/helpers.py you add:
from minwebhelpers import *
Then, inside a template you could have:
<head>
${ h.javascript_link('/js/file1.js',
'/js/file2.js',
minified=True,
combined=True,
combined_filename='all_javascript_files') }
${ h.stylesheet_link('/css/style1.css',
'/css/style2.css',
minified=True,
combined=True,
beaker_kwargs=dict(invalidate_on_startup=False)) }
</head>
The above would mean file1.js and file2.js would be combined and then minimized (same story for css files).
It’s as easy as:
sudo easy_install MinificationWebHelpers
Or if you wish to install current trunk:
sudo easy_install http://bitbucket.org/iElectric/minificationwebhelpers/get/tip.zip