Opened 17 years ago
Closed 17 years ago
#4123 closed (fixed)
firstof template tag doesn't accept strings with spaces
Reported by: | Owned by: | Matt Boersma | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Keywords: | firstof | |
Cc: | axiak@… | 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
When firstof is passed a quoted string with a space, ex. {% firstof var1 var2 var3 "fallback string" %}, it splits the string and reads the pieces as False. If the string is the last element in the firstof tag, then the whole thing returns False and firstof returns a blank string.
Attachments (2)
Change History (7)
by , 17 years ago
Attachment: | firstof_patch.diff added |
---|
comment:1 by , 17 years ago
Cc: | added |
---|---|
Has patch: | set |
Triage Stage: | Unreviewed → Accepted |
This seems like an obvious bug and fix.
I hope someone with more clout can verify this.
comment:2 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 17 years ago
Needs tests: | set |
---|---|
Triage Stage: | Accepted → Design decision needed |
The docs for the firstof tag make no mention of accepting literal strings, only variables. So my first inclination was "wontfix."
On the other hand, similar tags like "if" seem to handle literal strings as if they were (always True) variables. And token.split_contents is a more reliable method that is used elsewhere and arguably should be here too. Finally, having a "fallback string" as described here seems quite useful, although if we went that we it implies a documentation change.
I'll be glad to make the doc changes if a core developer decides this is worth doing, otherwise we should close it as wontfix.
by , 17 years ago
Patch with docs and tests for handling strings with spaces in the firstof tag.
comment:4 by , 17 years ago
Keywords: | firstof added |
---|---|
Needs tests: | unset |
Triage Stage: | Design decision needed → Ready for checkin |
comment:5 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Simple patch for firstof compilation function.