Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions djangojs/templatetags/js.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
'''
from __future__ import unicode_literals

import django
from distutils.version import StrictVersion

from django import template
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils import six
Expand All @@ -13,6 +16,11 @@

register = template.Library()

if StrictVersion(django.get_version()) >= StrictVersion("1.8"):
tokens = template.base
else:
tokens = template


def verbatim_tags(parser, token, endtagname):
'''
Expand All @@ -39,14 +47,14 @@ def verbatim_tags(parser, token, endtagname):
if token.contents == endtagname:
break

if token.token_type == template.TOKEN_VAR:
if token.token_type == tokens.TOKEN_VAR:
text_and_nodes.append('{{')
text_and_nodes.append(token.contents)

elif token.token_type == template.TOKEN_TEXT:
elif token.token_type == tokens.TOKEN_TEXT:
text_and_nodes.append(token.contents)

elif token.token_type == template.TOKEN_BLOCK:
elif token.token_type == tokens.TOKEN_BLOCK:
try:
command = token.contents.split()[0]
except IndexError:
Expand All @@ -63,7 +71,7 @@ def verbatim_tags(parser, token, endtagname):
raise
text_and_nodes.append(node)

if token.token_type == template.TOKEN_VAR:
if token.token_type == tokens.TOKEN_VAR:
text_and_nodes.append('}}')

return text_and_nodes
Expand Down