Django

Code

Show
Ignore:
Timestamp:
08/31/08 13:28:06 (3 months ago)
Author:
jacob
Message:

Fixed #7027: template tags now corectly break tokens around strings marked for translation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/template/__init__.py

    r8393 r8769  
    198198 
    199199    def split_contents(self): 
    200         return list(smart_split(self.contents)) 
     200        split = [] 
     201        bits = iter(smart_split(self.contents)) 
     202        for bit in bits: 
     203            # Handle translation-marked template pieces 
     204            if bit.startswith('_("') or bit.startswith("_('"): 
     205                sentinal = bit[2] + ')' 
     206                trans_bit = [bit] 
     207                while not bit.endswith(sentinal): 
     208                    bit = bits.next() 
     209                    trans_bit.append(bit) 
     210                bit = ' '.join(trans_bit) 
     211            split.append(bit) 
     212        return split 
    201213 
    202214class Lexer(object):