Django

Code

Ticket #5270 (closed: fixed)

Opened 1 year ago

Last modified 4 months ago

Template tags won't accept an empty string as an argument

Reported by: stephen Assigned to: jdunck
Milestone: 1.0 Component: Template system
Version: SVN Keywords: empty string tplrf-fixed
Cc: jdunck@gmail.com Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

There currently appears to be no easy to pass an empty string to a template tag.

{% url admin "" %} results in a TemplateSyntaxError?.

Some template tags (notable reverse URL lookups for the root of a newforms-admin instance) require an empty string to be passed in.

Attachments

empty-string.patch (0.8 kB) - added by rnairn@gmail.com on 05/23/08 18:56:10.
Patch to allow empty constant strings as filter arguments
5270-empty-string-template-w-tests.diff (2.9 kB) - added by jdunck on 08/15/08 11:54:57.
Added tests, and now handling the empty i18n constant specially for translation.

Change History

09/02/07 04:35:44 changed by Simon G. <dev@simon.net.nz>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Design decision needed.
  • needs_tests changed.
  • needs_docs changed.

01/19/08 21:13:12 changed by miracle2k

This is due to

if i18n_constant:
    var = '"%s"' %  _(i18n_constant.replace(r'\"', '"'))
elif constant:
    var = '"%s"' % constant.replace(r'\"', '"')

in FilterExpression?.init(), where the elif-clause should probably check for is None.

Would be nice if this could be fixed.

05/23/08 18:56:10 changed by rnairn@gmail.com

  • attachment empty-string.patch added.

Patch to allow empty constant strings as filter arguments

05/23/08 19:11:59 changed by r0wb0t

  • owner changed from nobody to r0wb0t.
  • status changed from new to assigned.
  • has_patch set to 1.

Added a patch

07/18/08 13:58:04 changed by emulbreh

  • keywords changed from empty string to empty string tplrf-fixed.

This would be fixed by the refactoring proposed in #7806.

08/11/08 10:14:27 changed by jacob

  • milestone set to 1.0.

08/15/08 11:54:57 changed by jdunck

  • attachment 5270-empty-string-template-w-tests.diff added.

Added tests, and now handling the empty i18n constant specially for translation.

08/15/08 12:56:05 changed by jdunck

  • cc set to jdunck@gmail.com.
  • stage changed from Design decision needed to Ready for checkin.

08/15/08 12:56:12 changed by jdunck

  • owner changed from r0wb0t to jdunck.
  • status changed from assigned to new.

08/15/08 12:56:16 changed by jdunck

  • status changed from new to assigned.

08/15/08 16:08:12 changed by gwilson

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [8393]) Fixed #5270 -- Allow template tags and filters to accept an emtpy string, patch from jdunck.


Add/Change #5270 (Template tags won't accept an empty string as an argument)




Change Properties
Action