Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Merge 392b4db into 890729d
Browse files Browse the repository at this point in the history
  • Loading branch information
geert2705 committed May 10, 2016
2 parents 890729d + 392b4db commit 6149678
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Empty file.
19 changes: 19 additions & 0 deletions responsive/templatetags/responsive_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django import template

register = template.Library()

@register.assignment_tag(takes_context=True)
def device_size(context):
"""Create a variable in context containing the devices' size
as recorded by django-responsive2
Usage in template: {% device_size as device_size %}
<div class="{{ device_size }}">...</div>
"""
device = context.get('device', '')
if device:
li = [key for key, value in \
device.match_media_queries().iteritems() if value]
device = ' '.join(li)
return device

0 comments on commit 6149678

Please sign in to comment.