Opened 15 years ago
Closed 15 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)
Changed 15 years ago by
Attachment: | firstof_patch.diff added |
---|
comment:1 Changed 15 years ago by
Cc: | axiak@… 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 Changed 15 years ago by
Owner: | changed from nobody to Matt Boersma |
---|---|
Status: | new → assigned |
comment:3 Changed 15 years ago by
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.
Changed 15 years ago by
Patch with docs and tests for handling strings with spaces in the firstof tag.
comment:4 Changed 15 years ago by
Keywords: | firstof added |
---|---|
Needs tests: | unset |
Triage Stage: | Design decision needed → Ready for checkin |
comment:5 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Simple patch for firstof compilation function.