#2800 closed enhancement (fixed)
[patch] Make ifchanged tag accept a parameter
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Template system | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The patch allows to pass a parameter to ifchanged, which is then evaluated and checked if it has changed, instead of the tag’s content. If it has changed the content is being printed, as usual. I.e. you can do
{% ifchanged variable %}print if variable's value has changed{% ifchanged %}
To know more about the details, read here.
Attachments (3)
Change History (9)
by , 18 years ago
Attachment: | enhanced-ifchanged.patch added |
---|
comment:1 by , 18 years ago
by , 18 years ago
Attachment: | ifchanged-tests.patch added |
---|
comment:2 by , 18 years ago
Summary: | Make ifchanged tag accept a parameter → [patch] Make ifchanged tag accept a parameter |
---|
comment:3 by , 18 years ago
The following updated patch allows for multiple parameters, such as:
{% ifchanged date.hour,date.date %}
Examples, doc and tests included.
by , 18 years ago
Attachment: | ifchanged-multi-parameters.patch added |
---|
comment:4 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
A little more explaination may be. In my case I had nested for loops and wanted to check if the outer had changed and modify something inside the inner loop.
That was impossible using ifchanged without telling what to look for if it had changed, so I enhanced ifchanged's syntax.
I hope you find it useful too.
Having ifchanged accept a parameter would be phantastic. Like so:
The ifchanged tag should be able to check if a certain variable has changed if given, otherwise work as usual.