Opened 17 years ago

Closed 16 years ago

Last modified 12 years ago

#5270 closed (fixed)

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

Reported by: stephen Owned by: Jeremy Dunck
Component: Template system Version: dev
Severity: Keywords: empty string tplrf-fixed
Cc: jdunck@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (2)

empty-string.patch (782 bytes ) - added by rnairn@… 16 years ago.
Patch to allow empty constant strings as filter arguments
5270-empty-string-template-w-tests.diff (2.9 KB ) - added by Jeremy Dunck 16 years ago.
Added tests, and now handling the empty i18n constant specially for translation.

Download all attachments as: .zip

Change History (12)

comment:1 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by miracle2k, 16 years ago

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.

by rnairn@…, 16 years ago

Attachment: empty-string.patch added

Patch to allow empty constant strings as filter arguments

comment:3 by Rowan Nairn, 16 years ago

Has patch: set
Owner: changed from nobody to Rowan Nairn
Status: newassigned

Added a patch

comment:4 by Johannes Dollinger, 16 years ago

Keywords: tplrf-fixed added

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

comment:5 by Jacob, 16 years ago

milestone: 1.0

by Jeremy Dunck, 16 years ago

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

comment:6 by Jeremy Dunck, 16 years ago

Cc: jdunck@… added
Triage Stage: Design decision neededReady for checkin

comment:7 by Jeremy Dunck, 16 years ago

Owner: changed from Rowan Nairn to Jeremy Dunck
Status: assignednew

comment:8 by Jeremy Dunck, 16 years ago

Status: newassigned

comment:9 by Gary Wilson, 16 years ago

Resolution: fixed
Status: assignedclosed

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

comment:10 by Jacob, 12 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top