summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Bicking <ianb@colorstudy.com>2010-09-02 01:12:34 -0500
committerIan Bicking <ianb@colorstudy.com>2010-09-02 01:12:34 -0500
commit2bd385beb755caee756b9e9c671a2854a430edd3 (patch)
treeaa2cefefafc3c35f56a60e121d80f866ddbba79f /tests
parentc141caca55a3ddab12c6cddfb3f84e9fd36926c2 (diff)
downloadtempita-2bd385beb755caee756b9e9c671a2854a430edd3.tar.gz
Fix cases where whitespace isn't stripped properly (when there are multiple directive-only lines next to each other).
Diffstat (limited to 'tests')
-rw-r--r--tests/test_template.txt29
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/test_template.txt b/tests/test_template.txt
index 60c3afb..7c66a7f 100644
--- a/tests/test_template.txt
+++ b/tests/test_template.txt
@@ -9,7 +9,7 @@ example::
'Hi Ian'
>>> Template('Hi {{repr(name)}}').substitute(name='Ian')
"Hi 'Ian'"
- >>> Template('Hi {{name+1}}').substitute(name='Ian')
+ >>> Template('Hi {{name+1}}').substitute(name='Ian') # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
TypeError: cannot concatenate 'str' and 'int' objects at line 1 column 6
@@ -59,7 +59,7 @@ Also Python blocks::
And some syntax errors::
- >>> t = Template('{{if x}}', name='foo.html')
+ >>> t = Template('{{if x}}', name='foo.html') # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
TemplateError: No {{endif}} at line 1 column 3 in foo.html
@@ -180,3 +180,28 @@ Then we'll define a template that inherits::
>>> print tmpl2.substitute(master='test2').strip()
Something:
+Whitespace
+==========
+
+Whitespace is removed from templates when a directive is on a line by
+itself. For example::
+
+ >>> #import sys; sys.debug = True
+ >>> tmpl = Template('''\
+ ... {{for i, item in enumerate(['a', 'b'])}}
+ ... {{if i % 2 == 0}}
+ ... <div class='even'>
+ ... {{else}}
+ ... <div class='odd'>
+ ... {{endif}}
+ ... {{item}}
+ ... </div>
+ ... {{endfor}}''')
+ >>> print tmpl.substitute()
+ <div class='even'>
+ a
+ </div>
+ <div class='odd'>
+ b
+ </div>
+ <BLANKLINE>