Django template tag to load static files inline with your template.
Project description
django-staticinline
Works similar to Django’s static templatetag, but this one includes the file directly in the template, rather than a link to it.
You can additionally post-process the file content using custom ‘encoder’.
Quickstart
Put the StaticInlineAppConfig along your apps.
INSTALLED_APPS = [ # ... 'staticinline.apps.StaticInlineAppConfig', ]
Load the template tag and pass a filename as you’d do with a static template tag. You can also post-process the file content. In the example below we encode the content of the mykey.pem file with base64. Several encoders are already built-in, see the Encoder docs.
{% load staticinline %} <style type="text/css">{% staticinline "myfile.css" %}</style> My base64 encoded Key: {% staticinline "mykey.pem" encode="base64" cache=True %}
Enjoy the result:
<style type="text/css">body{ color: red; }</style> My base64 encoded Key: LS0tIFN1cGVyIFByaXZhdGUgS2V5IC0tLQo=
Changelog
v1.3 (2018-08-15)
Added cache and cache_timeout templatetag arguments to store rendered values in cache.
Added data_response AppConfig method to globally override the template tag response.
v1.2 (2018-08-14)
Added support for Django 2.1 and Python 3.7.
Added proper documentation.
Added sri (Subresource Integrity) encoder to generate a sha256 for a given file.
v1.1 (2018-08-09)
Added support for custom data encoders to modify file content on the fly.
Added data and base64 encoders, both convert data into base64.
v1.0 (2018-04-29)
🌟 Initial release.
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
Built Distribution
File details
Details for the file django-staticinline-1.3.1.tar.gz
.
File metadata
- Download URL: django-staticinline-1.3.1.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d936460e8173d3b131379e3af419c42eb3f956efba34ec00eb7972e904d45ce |
|
MD5 | e81ec82e77df207e954e76ef0171d7ba |
|
BLAKE2b-256 | 8cde086b082026126fe6a70a91fc26a3074dfec37ec0fda7cd72e766f44982c6 |
File details
Details for the file django_staticinline-1.3.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_staticinline-1.3.1-py2.py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5499b5bcb53a2dcc62d500a149c597487e275d28aa4e1a5469fd7c1604f7a75 |
|
MD5 | 6a3df4799fb2649ef108afa416d57f0e |
|
BLAKE2b-256 | f22f4004777632a9876f0d66867794924aacc04ca4c0ba9b0c75810dc66e7abe |