Ticket #15092: 15092.patch

File 15092.patch, 2.2 KB (added by Aymeric Augustin, 13 years ago)
  • tests/regressiontests/templates/tests.py

     
    14621462
    14631463            ### NOW TAG ########################################################
    14641464            # Simple case
    1465             'now01': ('{% now "j n Y"%}', {}, str(datetime.now().day) + ' ' + str(datetime.now().month) + ' ' + str(datetime.now().year)),
    1466 
    1467             # Check parsing of escaped and special characters
    1468             'now02': ('{% now "j "n" Y"%}', {}, template.TemplateSyntaxError),
    1469         #    'now03': ('{% now "j \"n\" Y"%}', {}, str(datetime.now().day) + '"' + str(datetime.now().month) + '"' + str(datetime.now().year)),
    1470         #    'now04': ('{% now "j \nn\n Y"%}', {}, str(datetime.now().day) + '\n' + str(datetime.now().month) + '\n' + str(datetime.now().year))
     1465            'now01': ('{% now "j n Y" %}', {}, str(datetime.now().day) + ' ' + str(datetime.now().month) + ' ' + str(datetime.now().year)),
    14711466            # Check parsing of locale strings
    1472             'now05': ('{% now "DATE_FORMAT" %}', {},  date_format(datetime.now())),
     1467            'now02': ('{% now "DATE_FORMAT" %}', {},  date_format(datetime.now())),
     1468            # Also accept simple quotes - #15092
     1469            'now03': ("{% now 'j n Y' %}", {},  str(datetime.now().day) + ' ' + str(datetime.now().month) + ' ' + str(datetime.now().year)),
     1470            'now04': ("{% now 'DATE_FORMAT' %}", {},  date_format(datetime.now())),
    14731471
    14741472            ### URL TAG ########################################################
    14751473            # Successes
  • django/template/defaulttags.py

     
    10491049
    10501050        It is {% now "jS F Y H:i" %}
    10511051    """
    1052     bits = token.contents.split('"')
    1053     if len(bits) != 3:
     1052    bits = token.split_contents()
     1053    if len(bits) != 2:
    10541054        raise TemplateSyntaxError("'now' statement takes one argument")
    1055     format_string = bits[1]
     1055    format_string = bits[1][1:-1]
    10561056    return NowNode(format_string)
    10571057
    10581058@register.tag
Back to Top