Create a gist now

Instantly share code, notes, and snippets.

Django templatetags example
{% for p in posts %}
<li><a href="{{ a.url }}">{{ a.title }}</a>
{% endfor %}
# This should go in app/templatetags/
from django.template import Library
from app.models import Post
register = Library()
def latest_posts():
posts = Post.objects.order_by('-date')[:6]
return locals()
{% load app_tags %}
// Lots of HTML
{% latest_posts %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment