Skip to main content

Django template tag to load static files inline with your template.

Project description

https://travis-ci.org/bartTC/django-staticinline.svg?branch=master https://api.codacy.com/project/badge/Coverage/8e64345e99ea49888dc1bd9303c89a35 https://api.codacy.com/project/badge/Grade/8e64345e99ea49888dc1bd9303c89a35

django-staticinline

Similiar to Django’s native static templatetag, but this includes the file directly in the template, rather than a link to it.

Example:

{% load staticinline %}

<style type="text/css">{% staticinline "myfile.css" %}</style>
<script>{% staticinline "myfile.js" %}</script>

Becomes:

<style type="text/css">body{ color: red; }</style>
<script>alert("Hello World");</script>

If the file does not exist, and DEBUG is False, an empty string is returned and a error logfile is set. In case DEBUG is True, a ValueError is raised.

Installation

This Django app is compatible with Django 1.8 → 2.0, Python 2.7 all versions of Python 3.x.

Install with pip and add staticinline to your installed apps in your settings.py:

pip install django-staticinline

INSTALLED_APPS = [
    # ...
    'staticinline',
]

Changelog

v1.0 (2018-04-29)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-staticinline, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size django_staticinline-1.0.2-py2.py3-none-any.whl (6.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-staticinline-1.0.2.tar.gz (7.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page