(Ideally, though, template.py shouldn't care how many spaces/tabs are
used. It would be best if it could handle any indentation scheme that
you could do in plain Python.)
>
> Won't using .expandtabs() change tabs to eight spaces and screw things
> up because t.py only expects four?
>
no it doesnt.
The following test failes. but it gives resonable result.
lambda: t('$for x in [1, 2, 3]:\n\t$x')
(), '1\n2\n3\n',
AssertionError:
expected: '1\n2\n3\n'
got: ' 1\n 2\n 3\n'
That is perfectly fine for html.
If you try to make tabsize to 4, there can be problems in someother
places.
Python also treats tab as 8 spaces.
>>> exec("for i in range(3):\n a = i*i\n\tprint i,a")
0 0
1 1
2 4
>>> exec("for i in range(3):\n a = i*i\n\tprint i,a")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 3
print i,a
^
SyntaxError: invalid syntax
>>>
In the first example, i used 8 spaces and 4 in the latter one.
>
> On 16-Dec-06, at 5:07 AM, Aaron Swartz wrote:
>
>>
>> Won't using .expandtabs() change tabs to eight spaces and screw
>> things
>> up because t.py only expects four?
>>
>
>
> no it doesnt.
>
fixed. r134.
>
> What I'm really worried about is the 2-deep nesting scenario, like
> '$for i in x:\n\t$if i:\n\t\tfoo'. That should work.
Yes, it doesnt work. I will try to find a solution.