About tgext.webassets
tgext.webassets is a TurboGears2 extension for assets management based on WebAssets.
Installing
tgext.webassets can be installed from pypi:
pip install tgext.webassets
should just work for most of the users.
Usage
To enable tgext.webassets put inside your application config/app_cfg.py the following:
from tgext import webassets
webassets.plugme(base_config, bundles={
'js_all': webassets.Bundle('javascript/jquery.js', 'javascript/bootstrap.min.js',
filters='rjsmin', output='assets/js_all.js')
})
or you can use tgext.pluggable when available:
from tgext.pluggable import plug
from tgext.webassets import Bundle
plug(base_config, 'tgext.webassets', bundles={
'js_all': Bundle('javascript/jquery.js', 'javascript/bootstrap.min.js',
filters='rjsmin', output='assets/js_all.js')
})
By default tgext.webassets will load and save assets inside the turbogears static_files path. Which is usually the public directory inside your application.
The webassets environment will then be available as tg.app_globals.webassets, so you can use it inside your templates to load the assets:
<script py:for="asset_url in g.webassets.js_all.urls()" src="$asset_url"></script>
Each registered bundle will be available as a property of the g.webassets object inside templates.
Bundles
ŧgext.webassets accepts the bundles inside the bundles dictionary. Each entry can be a Bundle instance or a webassets loader in case you want to load bundles from a configuration file.
Configuring
Options available in WebAssets Environment are also available in tgext.webassets, pass them as arguments to the plug (inside the options dictionary when using tgext.webassets.plugme) or provide the through AppConfig or .ini file with webassets. namespace.
Some have values that are inherited from your project configuration if not specified:
debug: If webassets is running in debug mode or not, by default is False.
base_dir: The directory assets will be located. By default is your project static_files directory.
base_url: The url static assets are served, by default /. Use this option to serve them from a CDN.
cache: If we should use webassets cache (if boolean), or override default path to cache directory by default assets are cached inside the .webassets-cache directory inside base_dir.
Builtin Filters
tgext.webassets comes with builtin the rjsmin and cssmin filter, all webassets filters work if the required tools are available.
Metadata
Release files for tgext.webassets 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tgext.webassets-0.0.2.tar.gz | 4.0 kB | Without provenance | Details for tgext.webassets-0.0.2.tar.gz |
Release files / tgext.webassets-0.0.2.tar.gz
| Download URL | tgext.webassets-0.0.2.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb632cff14b957e858bb64ca680d3490284ac654e6d7c3ccac33282e4ef764d8
|
|
BLAKE2b-256 checksum How to use checksums |
bd8f3b6c83c5f3c2a023a4b3903798e5dbd2188a06d7b7d53573056f724a9ba3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for tgext.webassets 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.