Metadata-Version: 2.4
Name: django-simpleinliner
Version: 1.0.0
Summary: A simple Django app for inlining static files in templates
Home-page: http://github.com/BigglesZX/django-simpleinliner
Author: James Tiplady
Maintainer: James Tiplady
License: MIT
Keywords: django
Platform: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 5.2
Requires-Python: >=3.8,<4
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=4.2
Provides-Extra: dev
Requires-Dist: black~=25.9.0; extra == "dev"
Requires-Dist: Django~=5.2.8; extra == "dev"
Requires-Dist: flake8~=7.3.0; extra == "dev"
Requires-Dist: setuptools~=80.9.0; extra == "dev"
Requires-Dist: tox~=4.32.0; extra == "dev"
Requires-Dist: twine~=6.2.0; extra == "dev"
Requires-Dist: wheel~=0.45.1; extra == "dev"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: maintainer
Dynamic: platform
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# django-simpleinliner

A simple Django app for inlining static CSS and JS files in templates. Read CSS, JS or generic files from your static directories and insert their contents into your Django templates, wrapping in appropriate HTML tags if necessary.

## Rationale

Provides a quick and easy way to inline an entire JS or CSS file from staticfiles into a template, wrapping it in appropriate tags. [`django-compressor`](https://github.com/django-compressor/django-compressor) does this but I wanted something more lightweight, and also wanted to try my hand at writing a Django extension. Some inspiration and staticfile-handling code was taken from [`django-inlinecss`](https://github.com/roverdotcom/django-inlinecss/).

## Compatibility

The widget has been tested on all Python/Django version combinations [officially supported](https://docs.djangoproject.com/en/5.2/faq/install/#what-python-version-can-i-use-with-django) by the Django project:

|                | Django 4.2 | 5.0 | 5.1 | 5.2 |
|---------------:|:----------:|:---:|:---:|:---:|
| **Python 3.8** | ✔          |     |     |     |
| **3.9**        | ✔          |     |     |     |
| **3.10**       | ✔          | ✔   | ✔   | ✔   |
| **3.11**       | ✔          | ✔   | ✔   | ✔   |
| **3.12**       | ✔          | ✔   | ✔   | ✔   |
| **3.13**       |            |     | ✔   | ✔   |
| **3.14**       |            |     |     | ✔   |

If you need to use `django-simpleinliner` with Django 3, please use a version of the package prior to `1.0.0`.

## Installation

```
$ pip install django-simpleinliner
```

Add `simpleinliner` to your `INSTALLED_APPS` setting.

## Usage

Load the app at the top of your template:

```
{% load simpleinliner %}
```

Call `inlinecss`, `inlinejs` or `inlinegeneric` where you want to pull in a static file:

```
{% inlinejs 'path/to/my.js' %}

{% inlinecss 'path/to/my.css' %}

{% inlinegeneric 'path/to/my.svg' %}
```

The file will be inserted into the template each time the template is rendered, keeping it up to date. Note that when using `inlinegeneric` no wrapper tag will be rendered – this is designed for files such as SVGs that already include all necessary markup.

You can override the default attributes given to `<script>` and `<style>` tags generated by `simpleinliner` by including the following in your project settings:

```
SIMPLEINLINER_DEFAULT_TAG_ATTRIBUTES = {
    'script': {
        'type': 'text/javascript',
    },
    'style': {
        'type': 'text/css',
    },
}
```

Add or edit these as desired to change the attributes applied to these tags.

By default `simpleinliner` will silently fail (including an empty tag if using `inlinejs` or `inlinecss`) if the specified path doesn't exist. You can force it to raise an exception by setting `SIMPLEINLINER_RAISE_EXCEPTIONS` to `True` in your project settings.

## Development

If working locally on the package you can install the development tools via `pip`:

```shell
$ pip install -e .[dev]
```

Run the `runserver` to load the test template:

```shell
$ cd example_project
$ python manage.py runserver 0.0.0.0:8000
```

Run the basic test suite across environments using `tox`:

```shell
$ tox run
```

## Credits

Since version 0.2.5 this library bundles a lightly modified version 1.16 of the [`html`](https://pypi.org/project/html/) library (in `html.py`), as that library does not correctly install itself in modern python/setuptools environments and cannot be correctly imported.

## Issues, Suggestions, Contributions

...are welcome on GitHub. Thanks for your interest in `simpleinliner`!
