djangodjango-compressor

Can I have Django template tags inside a django-compressor tag?


For example:

{% compress css %}
    <link rel="stylesheet" href="{% static 'css/foo.css' %}">
    {% if foobar %}
    <link rel="stylesheet" href="{% static 'css/bar.css' %}">
    {% endif %}
{% endcompress %}

As above, can I have an if tag inside the compress tag? Does this work with the OFFLINE_COMPRESSION mode?


Solution

  • I tested it myself. The answer is no, as of Aug. 2018.

    A workaround maybe using multiple compress tags as mentioned by in the other answer.