Opened 17 years ago

Closed 16 years ago

#6296 closed (fixed)

[patch]ifequal, filter and hardcoded-string doesn't work

Reported by: philipp@… 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)

6296.diff (3.1 KB ) - added by Thejaswi Puthraya 17 years ago.
patch and tests

Download all attachments as: .zip

Change History (5)

comment:1 by Thejaswi Puthraya, 17 years ago

Cc: thejaswi.puthraya@… added
Has patch: set
Needs tests: set
Owner: changed from nobody to Thejaswi Puthraya
Status: newassigned
Triage Stage: UnreviewedAccepted

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.

by Thejaswi Puthraya, 17 years ago

Attachment: 6296.diff added

patch and tests

comment:2 by Thejaswi Puthraya, 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 Johannes Dollinger, 16 years ago

Keywords: tplrf-fixed added

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

comment:4 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: assignedclosed

(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.

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