Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/barttc/django-staticinline
Django template tag to load static files inline with your template.
https://github.com/barttc/django-staticinline
django performance staticfiles
Last synced: 19 days ago
JSON representation
Django template tag to load static files inline with your template.
- Host: GitHub
- URL: https://github.com/barttc/django-staticinline
- Owner: bartTC
- Created: 2018-04-29T14:41:03.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-08-11T11:24:31.000Z (3 months ago)
- Last Synced: 2024-10-13T12:50:49.751Z (about 1 month ago)
- Topics: django, performance, staticfiles
- Language: Python
- Homepage: https://django-staticinline.readthedocs.io/
- Size: 229 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
[![](https://badge.fury.io/py/django-staticinline.svg)](https://badge.fury.io/py/django-staticinline)
[![](https://github.com/bartTC/django-staticinline/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/bartTC/django-staticinline/actions)-----
📖 Full documentation: https://barttc.github.io/django-staticinline/
🐱 GitHub Repository: https://github.com/bartTC/django-staticinline# django-staticinline
Works similar to Django's `static` template tag, 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'.
## Compatibility Matrix:
| Py/Dj | 3.9 | 3.10 | 3.11 | 3.12 |
|-----------|-----|------|------|------|
| 3.2 (LTS) | ✓ | ✓ | ✓ | ✓ |
| 4.0 | ✓ | ✓ | ✓ | ✓ |
| 4.1 | ✓ | ✓ | ✓ | ✓ |
| 4.2 (LTS) | — | ✓ | ✓ | ✓ |
| 5.0 | — | ✓ | ✓ | ✓ |
| 5.1 | — | ✓ | ✓ | ✓ |## Quickstart
1. Put the StaticInlineAppConfig along your apps.
```python
INSTALLED_APPS = [
# ...
'staticinline.apps.StaticInlineAppConfig',
]
```
2. 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].```html
{% load staticinline %}
{% staticinline "myfile.css" %}
My base64 encoded Key: {% staticinline "mykey.pem" encode="base64" cache=True %}
```
3. Enjoy the result:```html
body{ color: red; }
My base64 encoded Key: LS0tIFN1cGVyIFByaXZhdGUgS2V5IC0tLQo=
```[Encoder docs]: https://docs.elephant.house/django-staticinline/encoder.html