pyramid_webassets
Project description
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.base_url=/static
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)
```
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.
====================
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.base_url=/static
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)
```
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyramid_webassets-0.1.tar.gz
(2.6 kB
view details)
File details
Details for the file pyramid_webassets-0.1.tar.gz
.
File metadata
- Download URL: pyramid_webassets-0.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0121f24d3a09a4e9a7796f14acdde66e8f9c27d653b076c3bb3c82292ea5c3dc |
|
MD5 | 84bd8b8d91755ea2ab1c0cfb45382da8 |
|
BLAKE2b-256 | 8be6aa017adafd0022a2f84c18295a73d5ade897f523e4f54057b036d4ce54c2 |