script tag with additional attributes for django.forms.Media
Project description
Usage
Use this to insert a script tag via forms.Media containing additional attributes (such as id and data-* for CSP-compatible data injection.):
media.add_js([ JS('asset.js', { 'id': 'asset-script', 'data-answer': '"42"', }), ])
The rendered media tag (via {{ media.js }} or {{ media }} will now contain a script tag as follows, without line breaks:
<script type="text/javascript" src="/static/asset.js" data-answer=""42"" id="asset-script"></script>
The attributes are automatically escaped. The data attributes may now be accessed inside asset.js:
var answer = document.querySelector('#asset-script').dataset.answer;
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 Distribution
django-js-asset-0.1.0.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file django-js-asset-0.1.0.tar.gz
.
File metadata
- Download URL: django-js-asset-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ed5e15d1c95e837476013e8846e05ec9f08f1f8ed28c2fe476ca6f392e7b725 |
|
MD5 | ea43a287f7d806bddfefcd6b2daf22ba |
|
BLAKE2b-256 | 5b021cded1da07c469ac282b20b975990235119eb1dcf1fa0dc3a039abcd6fd6 |
File details
Details for the file django_js_asset-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: django_js_asset-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a067819271e3df5bc4936e1c602dd1e3a8b3d3c634ee584963304ebeea2392f0 |
|
MD5 | 900293b55929277d7c124d28e34c2b88 |
|
BLAKE2b-256 | f2d93f71b7ab43b8a12527738637c58722530685e25a7580194c84d29cf24556 |