﻿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
12199	Give 'firstof' tag ability to assign result to context	Tim Valenta	craigls	"When you need to access fields on objects in a {{{ {% firstof %} }}} fashion, semantically 'optional' fields can cause issues:

{{{
    Today the teacher is {% firstof substitute.name teacher.name %},
    and drives a {% firstof substitute.car teacher.car %}
}}}

If {{{ substitute }}} doesn't have a value for {{{ car }}}, then it will fall back to {{{ teacher.car }}}.

The real issue is that {{{ {% firstof %} }}} cannot preserve its value for later multiple inspections.  If the {{{ {% firstof %} }}} tag could assign its result to a context variable, it would solve this problem:

{{{
    {% firstof substitute teacher as teacher_for_today %}
    Today the teacher is {{ teacher_for_today }}
    {% if teacher_for_today.car %}
        and drives a {{ teacher_for_today.car }}
    {% endif %}
}}}


I am unsure that this is possible to achieve without the {{{ as }}} syntax.  One would have to code a template tag or filter for the sole purpose of duplicating the exact functionality that I propose be added to {{{ {% firstof %} }}}.

Attached patch for functionality and documentation on the subject."	New feature	closed	Template system	dev	Normal	fixed	firstof, as, context		Accepted	1	0	1	0	0	0
