djangosnippets.org: Latest snippets tagged with 'whitespace'https://djangosnippets.org/tags/whitespace/2012-02-14T07:44:09.131828-06:00Skip only specified spaces
2012-02-14T07:44:09.131828-06:00axilhttps://djangosnippets.org/snippets/2686/<p>Similar to <code>{% spaceless %}</code>, but only removes spaces followed by a special marker (<code>&nosp;</code>).</p>
<p>Helps keeping proper indentation:</p>
<pre><code>{% skipspaces %}
Lots of coffee
{% if from_brazil %}
from Brazil
{% else %}
from Columbia
{% endif %}
{% if tea %}&nosp;, some tea{% endif %} …</code></pre>
Freely redistributableUpdated version of StripWhitespaceMiddleware (v1.1)
2011-05-31T13:01:47.425273-05:00sleepycalhttps://djangosnippets.org/snippets/2450/<p>Tightens up response content by removed superflous line breaks and whitespace.
By Doug Van Horn</p>
<p>---- CHANGES ----
v1.1 - 31st May 2011
Cal Leeming [Simplicity Media Ltd]
Modified regex to strip leading/trailing white space from every line, not just those with blank n.</p>
<p>---- TODO ----
* Ensure whitespace …</p>
Freely redistributablewhitespaceoptimize block tag
2008-09-14T05:27:21.115324-05:00peterbehttps://djangosnippets.org/snippets/1055/<p>This is a custom block tag and is used like this:</p>
<pre><code>{% load whitespaceoptimize %}
{% whitespaceoptimize "css" %}
/* CSS comment */
body {
color: #CCCCCC;
}
{% endwhitespaceoptimize %}
</code></pre>
<p>And when rendered you get this output:</p>
<pre><code>body{color:#CCC}
</code></pre>
<p>To install it, download the snippet and call it <code>myapp/templatetags/whitespaceoptimize.py</code>. …</p>
Freely redistributable