Code

Ticket #8880: lexer.txt

File lexer.txt, 665 bytes (added by hvendelbo, 6 years ago)

patch for django/template/init.py

Line 
1--- a/django/template/__init__.py
2+++ b/django/template/__init__.py
3@@ -35,6 +35,22 @@ will be raised if the template doesn't have proper syntax.
4 Sample code:
5 
6 >>> from django import template
7+>>> s = u'{% extends "base" %}{% block a %}--{% endblock %}'
8+>>> l = template.Lexer(s,'')
9+>>> tokens = l.tokenize()
10+
11+You will now have 3 block tokens and a text token
12+
13+>>> tokens[0].content
14+u'extends "base"'
15+>>> tokens[1].content
16+u' extends "base"'
17+>>> tokens[2].content
18+u' block a'
19+>>> tokens[3].content
20+u' endblock'
21+
22+>>> from django import template
23 >>> s = u'<html>{% if test %}<h1>{{ varvalue }}</h1>{% endif %}</html>'
24 >>> t = template.Template(s)