Outputs the contents of the block if the second argument matches (or not, depending on the tag) the regular expression represented by the first argument.
Usage:
{% ifregex "^/comments/" request.path %}
...
{% endifregex %}
{% ifnotregex "^/comments/" request.path %}
...
{% else %}
...
{% endifnotregex %}
A simple tag to render breadcrumbs.
Usage:
{% load breadcrumbs %}
{% breadcrumbs "['Home','Home','home']" "['Articles','Articles','articles']" "['object','object','object.get_absolute_url']" %}
Loads up the template in "modules/breadcrumbs.html" and renders it with a list of items.
You can provide the tag either with plain text stuff and named urls as the third argument ( any more arguments per bracket-block is parsed as args / kwargs for the reverse() call ) or the object directly, and the script tries after failing the reverse() to resolve the provided arguments.
Have pun.
A template filter which wraps imagemagick's `convert` command. The filter acts upon a source image path, and returns the filtered image path.
usage: {{ source_path|convert:"-resize 64x64\!" }}
The filter parameter is the processing arguments for an ImageMagick 'convert' command. See e.g. http://www.imagemagick.org/Usage/resize/
Every image created is saved in a cache folder. This code does not handle removing obsolete cached images. If the filtered image path exists already, no image processing is carried out, and the path is returned.
This TemplateTag simply returns a True when it is Naked CSS Day allowing you to hide your CSS or display a custom message on that date. Allows allows for parameters should the date change (again).
Looks up for a template based on the template-name plus the current users language code. Loads the template and renders it with the current context.
Example::
{% langinclude "foo/some_include.html" %}
Based on the users LANGUAGE_CODE, assumed we have 'de', it tries to render the template 'foo/some_include.html.de'. If that doesn't exists, it renders the template 'foo/some_include.html'. This is the default behavior of the include-Tag.
Basically this is a shortcut for the following code, just with a fallback for the default template::
{% ifequal LANGUAGE_CODE "de" %}
{% include "foo/some_include.html.de" %}
{% else %}
{% include "foo/some_include.html" %}
{% endifequal %}
---
Ein deutscher [Weblogeintrag mit Beschreibung](http://www.mahner.org/weblog/sprachabhangige-template-imports/)
Entirely based on and with big thanks to:
[http://www.tomanthony.co.uk/](http://www.tomanthony.co.uk/)
Drops in a googlemap with a placemarker based on a uk postcode
Looks like this:
{% googlemap_from_ukpostcode postcode "XxY" zoom %}
e.g.
{% googlemap_from_ukpostcode "SP27AS" "220x290" 16 %}
postcode and zoom can optionally be template variables.
"XxY" is the x/y size of the map you want to drop in.
zoom can be omitted and defaults to 14.
requires:
in settings: GOOGLE_AJAX_API_KEY, GOOGLE_MAPS_API_KEY
google_map_ukpostcodes.js: is slight variation on js at http://www.tomanthony.co.uk/demo/geocode_uk_postcode/gmap.js
For further and better info see:
[http://www.tomanthony.co.uk/blog/geocoding-uk-postcodes-with-google-map-api/](http://www.tomanthony.co.uk/blog/geocoding-uk-postcodes-with-google-map-api/)
Django tagging by default doesn't provide a templatetag to get the related objects for another object. Even though this is implemented as a model. Still, one can use the existing templatetags to achieve the same outcome.
Of course, writing a custom templatetag would be more efficient in terms of database access.
This is an extension of the snippet http://www.djangosnippets.org/snippets/1302/ to make it a bit more flexible and been able pass more than one parameter to our "Partial Template". To use it you can
{% partial_template template_name param1:variable1 param2:variable2 ... %}
or:
{% partial_template partials/mini_template.html item:data1 var2:"False" var3:"2*2" %}
Truncates a string after a given length, keeping the last word complete.
This filter is more precise than the default `truncatewords` filter.
Words length vary too much, 10 words may result in 40 or 70 characters, so cutting by character count makes more sense.
There is a [blog post](http://ricobl.wordpress.com/2008/12/23/templates-django-filtro-truncatewords-melhorado/) about this snippet (in Portuguese).
Something I end up doing all the time, making a boolean variable show up as a nice image. With this code you can do the following:
`{% boolean_img user.is_active %}`
And get the following output:
`<img src="/media/icons/accept.png" alt="True" />`
All you need to do is use the custom templatetag code, load it in your template and use the `boolean_img` tag.
**Adjust templates, html and images where needed**
This template tag takes the current GET query, and modifies or adds the value you specify. This is great for GET-query-driven views, where you want to provide URLs which reconfigure the view somehow.
**Example Usage:**
`{% get_string "sort_by" "date" %}` returns `all=your¤t=get&variables=plus&sort_by=date`
This template tag will attempt to apply pygments syntax highlighting to anything inside {% code %} and {% endcode %} tags. You can optionally pass in the language to highlight in the form of {% code 'lang' %} - if you don't, it will first try to guess the syntax, and then fall back to Python syntax highlighting.