jezdez/django_compressor — Issue #138: compress management command does not find compress tags inside of 'if' nodes.
Author: schickm
Created: 2011-10-15 18:39:19+00:00
State: open

I have some javascript that I always want loaded, and some that is conditionally loaded based on context vars. If I have a template with the following:

{% if edit_mode %}
{% compress js %}

...
{% endcompress %}
{% endif %}

This will work nicely when javascript compression happens inside of the request/response cycle, but it will get completely skipped if you try to generate the compressed javascript via 'manage.py compress'.

If the opposite route is taken and the tags are declared like:

{% compress js %}
{% if edit_mode %}

...
{% endif %}
{% endcompress %}

Then the compressed javascript is generated, however the 'if' tag get's complete tossed out. This causes the script tag to appear in generated html output regardless of what the context variable 'edit_mode' is set to.