Created on 10.8.2011
@author: xaralis
A context processor to add the current_site to the current Context.
Adds STATIC_URL to template context. Beneficial for pre-1.3 Django.
Special middleware for sites that should not be seen by general public.
If REMOTE_ADDR is not in INTERNAL_IPS setting, login form will be displayed and the person would not be let in until it fills the form correctly.
Add to MIDDLEWARE_CLASSES when you want to have all of your HTML reponses to be smaller.
Reduces the size of HTML response by applying strip_spaces_between_tags always.
Tag library that provides support for “macros” in Django templates.
Usage example:
<yourapp>/taglibrary/macros.py
{% load macros %}
Define a new macro called ‘my_macro’ with parameter ‘arg1’:
{% macro my_macro arg1 %} Parameter: {{ arg1 }} <br/> {% endmacro %}
{% usemacro my_macro “String parameter” %}
or with a variable parameter (provided the context defines ‘somearg’ variable, e.g. with value “Variable parameter”):
{% usemacro my_macro somearg %}
Parameter: String parameter <br/> Parameter: Variable parameter <br/>
Alternatively save your macros in a separate file, e.g. “mymacros.html” and load it to the current template with:
{% loadmacros “mymacros.html” %}
Then use these loaded macros in {% usemacro %} as described above.
Macros can take zero or more arguments and both context variables and macro arguments are resolved in macro body when used in {% usemacro ... %} tag.
Bear in mind that defined and loaded Macros are local to each template file and are not inherited through {% extends ... %} tags.