1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #3036 -- Fixed some doctest strings that were failing. Thanks to pterk for the original patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6268 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2007-09-15 08:29:56 +00:00
parent 671a8359e8
commit 84e824fbbf
5 changed files with 33 additions and 34 deletions

View File

@@ -34,14 +34,8 @@ will be raised if the template doesn't have proper syntax.
Sample code:
>>> import template
>>> s = '''
... <html>
... {% if test %}
... <h1>{{ varvalue }}</h1>
... {% endif %}
... </html>
... '''
>>> from django import template
>>> s = u'<html>{% if test %}<h1>{{ varvalue }}</h1>{% endif %}</html>'
>>> t = template.Template(s)
(t is now a compiled template, and its render() method can be called multiple
@@ -49,10 +43,10 @@ times with multiple contexts)
>>> c = template.Context({'test':True, 'varvalue': 'Hello'})
>>> t.render(c)
'\n<html>\n\n <h1>Hello</h1>\n\n</html>\n'
u'<html><h1>Hello</h1></html>'
>>> c = template.Context({'test':False, 'varvalue': 'Hello'})
>>> t.render(c)
'\n<html>\n\n</html>\n'
u'<html></html>'
"""
import re
from inspect import getargspec
@@ -529,10 +523,11 @@ class FilterExpression(object):
and return a list of tuples of the filter name and arguments.
Sample:
>>> token = 'variable|default:"Default value"|date:"Y-m-d"'
>>> p = FilterParser(token)
>>> p.filters
[('default', 'Default value'), ('date', 'Y-m-d')]
>>> p.var
>>> p = Parser('')
>>> fe = FilterExpression(token, p)
>>> len(fe.filters)
2
>>> fe.var
'variable'
This class should never be instantiated outside of the
@@ -647,7 +642,7 @@ def resolve_variable(path, context):
>>> c = {'article': {'section':'News'}}
>>> resolve_variable('article.section', c)
'News'
u'News'
>>> resolve_variable('article', c)
{'section': 'News'}
>>> class AClass: pass
@@ -655,7 +650,7 @@ def resolve_variable(path, context):
>>> c.article = AClass()
>>> c.article.section = 'News'
>>> resolve_variable('article.section', c)
'News'
u'News'
(The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.')
"""