Django

Code

Changeset 6724

Show
Ignore:
Timestamp:
11/28/07 15:04:05 (1 year ago)
Author:
mtredinnick
Message:

Fixed #5890 -- fixed the far edge-case of allowing constant strings inside
template template markers: we now treat embedded, escaped double quotes
consistently with constant string arguments to filters. Patch from Dmitri
Fedortchenko.

Files:

Legend:

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

    r6680 r6724  
    548548                var, constant, i18n_constant = match.group("var", "constant", "i18n_constant") 
    549549                if i18n_constant: 
    550                     var = '"%s"' %  _(i18n_constant
     550                    var = '"%s"' %  _(i18n_constant.replace(r'\"', '"')
    551551                elif constant: 
    552                     var = '"%s"' % constant 
     552                    var = '"%s"' % constant.replace(r'\"', '"') 
    553553                upto = match.end() 
    554554                if var == None: 
  • django/trunk/tests/regressiontests/templates/tests.py

    r6689 r6724  
    268268            # Embedded newlines make it not-a-tag. 
    269269            'basic-syntax24': ("{{ moo\n }}", {}, "{{ moo\n }}"), 
     270 
     271            # Literal strings are permitted inside variables, mostly for i18n 
     272            # purposes. 
     273            'basic-syntax25': ('{{ "fred" }}', {}, "fred"), 
     274            'basic-syntax26': (r'{{ "\"fred\"" }}', {}, "\"fred\""), 
     275            'basic-syntax27': (r'{{ _("\"fred\"") }}', {}, "\"fred\""), 
    270276 
    271277            # List-index syntax allows a template to access a certain item of a subscriptable object.