Задать вопрос

Тел: +7 965 3737 888

483

Просмотров

1

Ответов

whitespaceoptimize block tag

<p>This is a custom block tag and is used like this:</p>
{% load whitespaceoptimize %}
{% whitespaceoptimize "css" %}
/* CSS comment */
body {
   color: #CCCCCC; 
}
{% endwhitespaceoptimize %}

<p>And when rendered you get this output:</p>
body{color:#CCC}

<p>To install it, download the snippet and call it myapp/templatetags/whitespaceoptimize.py. (Make sure you have a __init__.py in the templatetags directory)
You need to download and install <a href="http://www.issuetrackerproduct.com/Download#slimmer">slimmer</a> and put on your Python path. </p>
<p>The block tag can be used for javascript and html as well as css. You can also let it guess the format; this would work for example:</p>
{% whitespaceoptimize %}
&lt;table&gt; 
   &lt;tr&gt; ...
{% endwhitespaceoptimize %}

<p>...but this would just replicate the functonality of the <a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/#spaceless">built-in spaceless tag</a></p>

Вопрос полезен? Да0/Нет0
file_4467.py(1.3Кб)
None

Ответы (1):

Ответpeterbe:14.09.2008
Ответ полезен? Да0/Нет0

The slimmer is very fast but will nevertheless cost a few milliseconds on each slimming. Adding a memoize pattern shouldn't be too hard. However, you have to keep in mind that the reason for doing this is not to obscure css, js or html but to make the downloadable object smaller which would save bandwidth.