django-compressor/django-compressor — pull request #488 by lucastan (2014-03-13 14:44:30+00:00)
Title: Offline compression for Jinja2 with Jingo and Coffin integration

I'm done with offline support for jinja2.

I have added the setting:
```
# function that returns an Environment, which serves as an integration point for Jingo and Coffin.
COMPRESS_JINJA2_GET_ENVIRONMENT
```

Usage
======
`./manage.py compress -engine {jinja2,django}`
Default engine is Django.

Using with Jingo or Coffin
====================
See `test_offline.py` (bottom of the file) to see how to use the setting to get coffin's or jingo's env.

Using both Django and Jinja2 templates
===============================
I think it is somewhat supported in the sense that when Jinja2 engine is used to parse Django templates (and vice versa), the TemplateSyntaxError will be thrown and thereby skipping the templates. This fact can be exploited to support mixing of Django and Jinja2 templates in the same project (indicated by TEMPLATE_DIRS).

A user could, do the following:
specify TEMPLATE_DIRS to include both Django and Jinja2 locations.
`./manage.py compress ` => Process Django templates, skipping Jinja2 templates.
`./manage.py compress -engine jinja2` => Process Jinja2 templates, skipping Django templates.

Although for robustness, we should have a parameter to indicate specific Jinja2 template locations.

Limitations
==========
- May not support {% import %} and etc. blocks within {% compress %} blocks. Actually this is not tested, so it may or may not work. {% if %}, {% with %} and {% for %} are tested though.

- Does not support {{super()}} for now.