Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

banner_tags as a inclusion tag #4

Merged
merged 1 commit into from

2 participants

Héctor Rojas González Arvyd Paeglit
Héctor Rojas González

Tag modified to use it as a inclusion tag in templates in the next way:
{% load banner_tags %}

{% get_banner 'slug' width height %}

Arvyd Paeglit Arvi3d merged commit a938825 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 20, 2014
  1. Héctor Rojas González
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 8 deletions.
  1. +8 −8 src/banner/templatetags/banner_tags.py
16 src/banner/templatetags/banner_tags.py
View
@@ -1,16 +1,16 @@
### -*- coding: utf-8 -*- ####################################################
from django.conf import settings
-from native_tags.decorators import function
+from django import template
+from banner.models import Banner
-from ..models import Banner
+register = template.Library()
+@register.inclusion_tag('banner_source.html')
def get_banner(slug, width, height, queryset=Banner.objects.all()):
banner = queryset.get_or_create(slug=slug.encode('utf-8'))[0]
- return "banner_source.html", {
- 'banner': banner, 'size': "%ix%i" % (width, height),
- 'width': width, 'height': height,
- 'STATIC_URL': settings.STATIC_URL,
+ return {
+ 'banner': banner, 'size': "%ix%i" % (width, height),
+ 'width': width, 'height': height,
+ 'STATIC_URL': settings.STATIC_URL,
}
-
-get_banner = function(get_banner, inclusion=True, cache=60)
Something went wrong with that request. Please try again.