djangosnippets.org: Latest snippets posted by mludvighttps://djangosnippets.org/users/mludvig/2007-08-10T20:54:25.931257-05:00mludvigSupport for {% macro %} tags in templates, version 2
2007-08-10T20:54:25.931257-05:00mludvighttps://djangosnippets.org/snippets/363/<p>Tag library that provides support for <em>macros</em> in Django templates.</p>
<p><strong>Usage example:</strong></p>
<p><strong>0)</strong> Save this file as</p>
<pre><code><yourapp>/templatetags/macros.py
</code></pre>
<p><strong>1)</strong> In your template load the library:</p>
<pre><code>{% load macros %}
</code></pre>
<p><strong>2)</strong> Define a new macro called 'my_macro' with parameter 'arg1':</p>
<pre><code>{% macro my_macro arg1 %}
Parameter: {{ arg1 }}
{% endmacro …</code></pre>
Freely redistributable