﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16146	Calling functions with arguments inside a template	pmandel@…	nobody	"It would be incredibly useful to be able to call functions with arguments inside a Django template.

Imagine we are looping through a set of articles:
{{{
<table>
{% for a in articles %}
<tr><td>{{ a.title }}</td></tr>
{% endfor %}
</table>
}}}
And we want to change the color of articles the current user has already read (at some point prior to the current browser session, presumably).  Under the current framework, there's no straightforward way to do this.  Ideally, we'd create a function inside the poll class that would perform the check for us: 
{{{ 
def has_been_read_by(self, user)
}}}
So in the template, we'd get:
{{{
<table>
{% for a in articles %}
<tr><td {% if a.has_been_read_by %}style=""color:magenta;""{% endif %}>{{ a.title }}</td></tr>
{% endfor %}
</table>
}}}
However, since we can't pass an argument to the function in the template, this is currently impossible.  The best way I've figured out to do this is to perform all these checks view-side and zip up the information along with the object into a list of dictionaries that the template can unpack.  Ugly.

I propose that we consider allowing some form of arguments through functions in the template, be it with the '|arg', the ':arg' or the good old '(arg)' notation."	New feature	closed	Template system	1.3	Normal	wontfix	template, function	Matthijs Kooijman	Unreviewed	0	0	0	0	0	0
