Works exactly like the standard "extends" tag but enables one to fallback on a default template. This tag is LIMITED, as it falls back to the next template with the same name that DOES NOT contain "extends_default" (does NOT simulate full inheritance, just a single level).
A partial solution to problems like http://jeffcroft.com/blog/2008/aug/05/default-templates-django/.
MIT licensed.
This template tag allows easy inclusion of google analytics script. If Google changes the script in the future, it remains easy to update the template tag with the the new code. This script is tested against Django 1.0 trunk Oct 9 2008.
**Readme**
After signing up for a Google Analytics account for your domain, define ANALYTICS_ID = "UA-XXXXXXX-X" in your settings.py with the supplied code.
Include {% load analytics %} at the top of your base.html and {% analytics %} tag at just before the closing 'body' tag of the base template.
Make a template to hold the analytics script.
templates/analytics/analytics_html
**updated 12/16/08**
I run several blogs by visual-artists and web-designers who want a quick way to insert images into their blog without the awkwardness of WSYIWYG and without the technicality of code (eww...).
Thanks in advance for your input.
#Syntax in a blog goes:
[[thumb:the-image-slug]] # Gives you a thumbnail
[[image:the-image-slug]] # Presents full-size-image
Then of course:
{% blog.post|yeagowiki %}
You will also need to create some templates (see snippet). Here's a sample:
<!-- /templates/photologue/image_snippet.html -->
<div class="photologue-image">
<a href="{% if url %}{{ url }}{% else %}/media/{{ image.image }}{% endif %}">
<img src="{{ image.get_display_url }}" />
</a>
<p class="photologue-image-caption">{{ image.caption }}</p>
</div>
The `{% switch %}` tag compares a variable against one or more values in
`{% case %}` tags, and outputs the contents of the matching block. An
optional `{% else %}` tag sets off the default output if no matches
could be found:
{% switch result_count %}
{% case 0 %}
There are no search results.
{% case 1 %}
There is one search result.
{% else %}
Jackpot! Your search found {{ result_count }} results.
{% endswitch %}
Each `{% case %}` tag can take multiple values to compare the variable
against:
{% switch username %}
{% case "Jim" "Bob" "Joe" %}
Me old mate {{ username }}! How ya doin?
{% else %}
Hello {{ username }}
{% endswitch %}
Best practice based on [YSlow recommendations](http://developer.yahoo.com/yslow/), add the following to your Apache config for your media directory.
<Directory /home/.../site_media/>
...
FileETag None
ExpiresActive on
ExpiresDefault "access plus 10 years"
AddOutputFilterByType DEFLATE text/css application/x-javascript
</Directory`
Make sure to enable mod_deflate and mod_expires.
Requires [GitPython](http://gitorious.org/projects/git-python).
Grabs the most recent commits to a Git repository, as defined in `settings.py`. Inspired by [Simon Willison](http://simonwillison.net)'s [about page](http://simonwillison.net/about/).
**Example:**
{% get_recent_commits 10 as commits %}
<ul>
{% for commit in commits reversed %}
<li>{{ commit.commited_date }} - {{ commit.message }}</li>
{% endfor %}
</ul>
Often times I want to be able to interchangeably pass either literal strings or context variables to a custom templatetag. This function first checks a string for the existence of surrounding quotes and uses the string inside. If the string didn't explicitly use quotes it checks to see if it can resolve the string as a context variable. As a fallback the function will simply return the full string.
Example:
{% get_latest_by_tag 'django' %}
{% get_latest_by_tag object.tag %}
Parse a string for [BBCode](http://en.wikipedia.org/wiki/Bbcode) and generate it to (X)HTML by using the [postmarkup libary](http://code.google.com/p/postmarkup/).
In your template for generating (X)HTML:
{% load bbcode %}
{{ value|bbcode }}
In your template for removing BBCode fragments:
{% load bbcode %}
{{ value|strip_bbcode }}
Extension of the idea from [WuzHere example from Google IO](http://code.google.com/p/wuzhere/) about creating one compressed js or css file. Original code used not very elegant if statements. I've changed it to template tags. On production server it will also use current version id.
Insert code in *cssjs.py* file in *templatetags* dir in your application and use as below (more details in docs):
`<script type="text/javascript" src="/media/jsmergefile.js"></script>`
**This code does not compress CSS and JS on the fly, because GAE is read-only and using Datastore is too heavy.**
Set a context variable with the returned value by any templatetag.
Useful for example in order to use url templatetag inside blocktrans:
` {% withtag url my_app.views.my_view as my_view_url %}`
` {% blocktrans %}`
` Click <a href="{{ my_view_url }}">here</a>`
` {% endblocktrans %}`
` {% endwithtab %}`
Or with include templatetag:
` {% withtag include "js_template.js" as js_template %}`
` {{ js_template }}`
` {% endwithtab %}`
It works properly with your own custom templatetags.