Changeset 8769
- Timestamp:
- 08/31/08 13:28:06 (3 months ago)
- Files:
-
- django/trunk/django/template/__init__.py (modified) (1 diff)
- django/trunk/tests/regressiontests/templates/tests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/template/__init__.py
r8393 r8769 198 198 199 199 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 201 213 202 214 class Lexer(object): django/trunk/tests/regressiontests/templates/tests.py
r8766 r8769 130 130 test_template_sources('/DIR1/index.HTML', template_dirs, 131 131 ['/dir1/index.html']) 132 133 def test_token_smart_split(self): 134 # Regression test for #7027 135 token = template.Token(template.TOKEN_BLOCK, 'sometag _("Page not found") value|yesno:_("yes,no")') 136 split = token.split_contents() 137 self.assertEqual(split, ["sometag", '_("Page not found")', 'value|yesno:_("yes,no")']) 132 138 133 139 def test_templates(self):
