djangosnippets.org: Latest snippets posted by gsf0http://djangosnippets.org/users/gsf0/2009-10-21T17:18:47.327624-05:00gsf0middleware for user_passes_test
2009-10-21T17:18:47.327624-05:00gsf0http://djangosnippets.org/snippets/1768/<p>Middleware to decorate views with user_passes_test in a centralized, url-matching manner. Makes it easy to apply permissions across large sections or all of a site.</p>
Freely redistributablematch filter
2009-08-14T08:38:23.757223-05:00gsf0http://djangosnippets.org/snippets/1686/<p>A filter that re.matches a regex against a value. Useful for nav bars as follows:</p>
<pre><code>{% if location.path|match:"/$" %} class="current"{% endif %}
</code></pre>
<p>For <code>location.path</code> see my <a href="/snippets/1685/">location context_processor</a>.</p>
Freely redistributablelocation context_processor
2009-08-14T08:31:58.699023-05:00gsf0http://djangosnippets.org/snippets/1685/<p>A simple context_processor to include location info. Useful for permalinks, site name references, and navigation bars. For example:</p>
<pre><code>{% if location.path|match:"/$" %} class="current"{% endif %}
</code></pre>
<p>See also my <a href="/snippets/1686/">match filter</a>.</p>
Freely redistributablesimple string formatting filter
2007-08-27T15:09:19.279002-05:00gsf0http://djangosnippets.org/snippets/393/<p>I use this filter quite a bit to keep my templates less cluttered. Instead of:</p>
<pre><code>{%if some_variable%}, {{some_variable}}{%endif%}
</code></pre>
<p>I can write:</p>
<pre><code>{{some_variable|format:", %s"}}
</code></pre>
<p>A common one I use is:</p>
<pre><code>{{some_variable|format:"<p>%s</p>"}}
</code></pre>
Freely redistributable