Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install pyramid-webassets

How to install pyramid_webassets

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install pyramid-webassets
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1
0.7.1Never BuiltWhy not?
0.1 Available View build log
Windows (64-bit)
0.1
0.7.1Never BuiltWhy not?
0.1 Available View build log
Mac OS X (10.5+)
0.1
0.7.1Never BuiltWhy not?
0.1 Available View build log
Linux (32-bit)
0.7.1 Available View build log
0.7 Available View build log
0.1 Available View build log
Linux (64-bit)
0.7.1 Available View build log
0.7 Available View build log
0.1 Available View build log
 
Author
Lastest release
version 0.7.1 on Nov 21st, 2012
Configuration
====================
You are required to set base_dir and base_url, the rest are optional,
but we currently support:

 * base_dir: The directory to output and search for assets
 * base_url: The url static assets will be located
 * debug: If webassets should be in debug mode (i.e no compression)
 * updater: Different update configurations (i.e always, timestamp)
 * cache: If we should use webassets cache
 * jst_compiler: A custom jst compiler, by defalut it uses underscore

``` python
webassets.base_dir=%(here)s/app/static
webassets.base_url=/static
webassets.debug=True
webassets.updater=timestamp
webassets.cache=False
webassets.jst_compiler=Handlebars.compile
 ```

Then you can just use config.add_webasset to add bundles to your environment

``` python
    jst = Bundle('templates/*.html',
            filters='jst',
            output='js/jst.js', debug=False)

    config.add_webasset('jst', jst)
 ```

 Mako
====================
You can use the global webassets tag:
``` python
    % for url in webassets(request, 'css/bootstrap.css', 'css/bootstrap-responsive.css', output='css/generated.css', filters='cssmin'):
        
    % endfor
```

or you can grab the environment from the request.

From The Request
====================
If you are not using Jinja2, you can still access the environment from the request.

```python
    jst_urls = request.webassets_env['jst'].urls()
 ```


Jinja2
====================
If you are using Jinja2, you can just do the following configuration (this assumes use of pyramid_jinja2):

``` python
    config.add_jinja2_extension('webassets.ext.jinja2.AssetsExtension')
    assets_env = config.get_webassets_env()
    jinja2_env.assets_environment = assets_env
 ```

Extras
====================
There are a few utility methods you can use:

get_webassets_env_from_settings(settings, prefix='static_assets'): Pass it a dictionary of your settings and an
optional keyword argument of the prefix in your configuration and it will return you a webassets environment.

get_webassets_env(request or config): This will pull the environment out of the registry, you can use either
a configurator object or a request.

Subscribe to package updates

Last updated Nov 21st, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.