ff0000/django-start — Issue #20: Add verbatim tag to django-start
Author: gigafied
Created: 2011-11-08 22:12:53+00:00
State: open

Pretty much a must for any project where the front-end uses jQuery templates.

@register.tag
def verbatim(parser, token):
text = []
while 1:
token = parser.tokens.pop(0)
if token.contents == 'endverbatim':
break
if token.token_type == template.TOKEN_VAR:
text.append('{{')
elif token.token_type == template.TOKEN_BLOCK:
text.append('{%')
text.append(token.contents)
if token.token_type == template.TOKEN_VAR:
text.append('}}')
elif token.token_type == template.TOKEN_BLOCK:
text.append('%}')
return VerbatimNode(''.join(text))