Opened 17 years ago
Closed 16 years ago
#6296 closed (fixed)
[patch]ifequal, filter and hardcoded-string doesn't work
Reported by: | Owned by: | Thejaswi Puthraya | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Keywords: | ifequal filter hardcoded string tplrf-fixed | |
Cc: | thejaswi.puthraya@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi, I just experienced the following problem:
Let:
>>> url = "/home/test/" >>> urlparts = url.trim("/").split("/") ['home', 'test']
In the template I have:
{% ifequal urlparts|first "home" %}test1{% endifequal %} {% ifequal urlparts|first home %}test2{% endifequal %}
Only the "test2" gets shown.
Attachments (1)
Change History (5)
comment:1 by , 17 years ago
Cc: | added |
---|---|
Has patch: | set |
Needs tests: | set |
Owner: | changed from | to
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 17 years ago
Needs tests: | unset |
---|---|
Summary: | ifequal, filter and hardcoded-string doesn't work → [patch]ifequal, filter and hardcoded-string doesn't work |
This ticket looks very similar to #5756. But that ticket includes nodes like Cycle Node and Ifchanged Node. Since making such a big change would require a design decision, I have patched only for the Ifequal node.
comment:3 by , 16 years ago
Keywords: | tplrf-fixed added |
---|
This would be fixed by the refactoring proposed in #7806.
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [10119]) Fixed #5756, #6296 -- Most template tags can now handle filters in arguments.
Most of the hard work for this was done by akaihola.
There are still possibly some problems with the i18n template tags,
since they are written quite differently and a few other bug fixes have
to made before they can be fixed.
The problem with ifequal is that it accepts only variables and doesn't allow any filters. So the urlparts|first variable is not resolved. In the second case (mentioned in the ticket) when home (or any values say abc) is given, this variable too gets resolved as None (because it is neither a Float, Integer or String) in the IfEqual Node and hence the equality case arises.
I have added patches by replacing the Variable with a FilterExpression. Even if a plain Variable is given it gets resolved without any problems. I shall add a couple of tests very soon.