Metadata-Version: 2.1
Name: django-staticinline
Version: 1.5
Summary: Django template tag to load static files inline with your template.
Home-page: https://github.com/bartTC/django-staticinline
License: MIT
Keywords: django,staticfiles,inline,performance
Author: Martin Mahner
Author-email: martin@mahner.org
Requires-Python: >=3.9,<4.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: django (>=3.2)
Project-URL: Bugtracker, https://github.com/bartTC/django-staticinline/issues
Project-URL: Source, https://github.com/bartTC/django-staticinline
Description-Content-Type: text/markdown

[![](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/<br/>
🐱 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 %}
   
   <style>{% staticinline "myfile.css" %}</style>
   My base64 encoded Key: {% staticinline "mykey.pem" encode="base64" cache=True %}
    ```
   
3. Enjoy the result:

   ```html
   <style>body{ color: red; }</style>
   My base64 encoded Key: LS0tIFN1cGVyIFByaXZhdGUgS2V5IC0tLQo=
   ```

[Encoder docs]: https://docs.elephant.house/django-staticinline/encoder.html

# Changelog

## v1.5 (2024-08-11)

- Django 5.0, 5.1 compatibility and tests.
- Python 3.12 compatibility and tests.
- Type annotations.
- Switch from pipenv to Poetry.

## v1.4 (2023-04-29)

- Django 3.2 to 4.2 compatibility and tests.
- Python 3.8 to 3.11 compatibility and tests.

## 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.

