Makes it easy to manage front-end dependencies for Wagtail admin plugins
Project description
Wagtail Dependencies
====================
This package for Wagtail makes it easy to manage front-end dependencies for admin plugins.
#### The problem
Multiple Wagtail plugins may require the same front-end dependency, ex. Font Awesome. But we don't want to require that dependency twice on the admin screen, so we need to detect that duplication and only include it only once.
#### The solution
We can use named dependencies to prevent duplication, as long as developers can agree to use the same name. For instance, if we name Font Awesome `fontawesome`, then multiple projects can enqueue the `fontawesome` CSS, and this app will be sure it's only imported once.
Usage
-----
Add `wagtaildependencies` to your `INSTALLED_APPS`, then you can use the following hooks:
* `enqueue_scripts`
* `enqueue_styles`
The system will automatically detect duplicates among enqueued media throughout apps and will only include the library once.
Example
-------
```python
@hooks.register('enqueue_scripts')
def enqueue_jquery():
return {
'jquery': {
'source': 'lib/js/jquery.js',
'version' '3.1.0',
}
}
@hooks.register('enqueue_styles')
def enqueue_fontawesome():
return {
'fontawesome': {
'source': 'lib/css/fontawesome.css',
'version': '4.6.3',
}
}
```
====================
This package for Wagtail makes it easy to manage front-end dependencies for admin plugins.
#### The problem
Multiple Wagtail plugins may require the same front-end dependency, ex. Font Awesome. But we don't want to require that dependency twice on the admin screen, so we need to detect that duplication and only include it only once.
#### The solution
We can use named dependencies to prevent duplication, as long as developers can agree to use the same name. For instance, if we name Font Awesome `fontawesome`, then multiple projects can enqueue the `fontawesome` CSS, and this app will be sure it's only imported once.
Usage
-----
Add `wagtaildependencies` to your `INSTALLED_APPS`, then you can use the following hooks:
* `enqueue_scripts`
* `enqueue_styles`
The system will automatically detect duplicates among enqueued media throughout apps and will only include the library once.
Example
-------
```python
@hooks.register('enqueue_scripts')
def enqueue_jquery():
return {
'jquery': {
'source': 'lib/js/jquery.js',
'version' '3.1.0',
}
}
@hooks.register('enqueue_styles')
def enqueue_fontawesome():
return {
'fontawesome': {
'source': 'lib/css/fontawesome.css',
'version': '4.6.3',
}
}
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file wagtaildependencies-0.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: wagtaildependencies-0.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1efecdadc075e9bf42ae01add75df237c2710b49dd48b4cc1ba074d887d28c09 |
|
MD5 | 282f084ea34d686b6c4dcbf8d44b5d44 |
|
BLAKE2b-256 | 75c926fc9560353b119e73def293225b9c5c6d94f5f9a91812168b0dee826969 |