Skip to main content

Django application for adding compressed CSS and JS files in some prepared slots

Project description

django-bundledmedia is a Django application for adding compressed CSS and JS files in some prepared slots.

This functionality was splitted out of Merengue CMS.

Installing

  • Install package from pypi:

    $ easy_install django-bundledmedia
  • Include bundledmedia in the INSTALLED_APPS setting.

  • Include bundledmedia.middleware.BundledMediaMiddleware in the MIDDLEWARE_CLASSES setting.

Usage

In your base template (i.e. base.html):

{% load bundledmedia %}
<html>
 <head>
 {# placeholder to allow plugins and other templates to add css assets #}
 {% bundledmedia "css" %}
 </head>
 <body>
  ...
  {# placeholder to allow plugins and other templates to add javascript assets #}
  {% bundledmedia "js" %}
 </body>
</html>

In your included template (i.e. inc.myblock.html):

{% load bundledmedia %}
{% addmedia "css" %}
  <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/myblock.css"/>
{% endaddmedia %}
{% addmedia "js" %}
  <script language="javascript" src="{{ MEDIA_URL }}js/jquery.myblock.js"></script>
{% endaddmedia %}
...

This code will render all chunks of code of all the included templates in the placeholders above.

Compression

django-bundledmedia uses django-compressor to render compressed CSS and JS when the COMPRESS setting is set to True

0.1a

  • Initial version.

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

django-bundledmedia-0.1a.tar.gz (11.4 kB view details)

Uploaded Source

File details

Details for the file django-bundledmedia-0.1a.tar.gz.

File metadata

File hashes

Hashes for django-bundledmedia-0.1a.tar.gz
Algorithm Hash digest
SHA256 324ac1faf18a241015822fb6df5ada70c0e6a643358faecabc238cf5c288e987
MD5 81b490c280fc39b6ad1938ca9615133c
BLAKE2b-256 af35cc39a98bbe7f7f03166b15cbe2929cbdf5d767267b2fd7c428275a52fcef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page