This module provide mako template support for Django Compressor.
All you need to do is to import extension namespace and using it with mako syntax:
<%namespace name="compress" module="django_compressor_mako"/>
<%compress:compress kind="css">
<link rel="stylesheet" href="/static/css/style.css" type="text/css" />
</%compress:compress>
Almost all django-compressor arguments are supported but must be explicitly named:
kind
: mandatory, "css" or "js".mode
: optional, compressor mode, "file" or "inline".name
: is not supported and will raise aNotImplementedError
Outputs cannot be named and are just named using hash plus extension.
Also note that mako template doesn't allow blocks inside of <%call>
, that
means you cannot use the following syntax:
<%namespace name="compress" module="django_compressor_mako"/>
<%compress:compress kind="css">
<%block name="more_css"/>
</%compress:compress>
In order to use offline compression you must first create cached compressed
files and manifest using python ./manage.py compress_mako
.
Additionally two shorter functions are provided, css
and js
, same
arguments can be passed except kind
which is set by default depending on
which one is used, eg.:
<%namespace name="compress" module="django_compressor_mako"/>
<%compress:css>
<link rel="stylesheet" href="/static/css/style.css" type="text/css" />
</%compress:css>
<%compress:js>
<script type="text/javascript" src="/static/js/script.js">
</%compress:js>