Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

banner_tags as a inclusion tag #4

Merged
merged 1 commit into from Jul 21, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/banner/templatetags/banner_tags.py
@@ -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)