Add a getattr template filter for retrieving an object's attribute.

Review Request #11049 — Created June 20, 2020 and submitted — Latest diff uploaded

Information

Djblets
release-2.0.x

Reviewers

This filter allows a template to get an attribute of an object without
hard-coding the attribute name up-front. It's useful for cases where you
might be operating off attribute names provided to the template or
computed by another tag.

It's similar to |getitem:... but uses a getattr(obj, key) call
instead of obj[key].

Unit tests passed.

Made use of this in another change.

Diff Revision 1 (Latest)

Commits

First Last Summary ID Author
Add a getattr template filter for retrieving an object's attribute.
This filter allows a template to get an attribute of an object without hard-coding the attribute name up-front. It's useful for cases where you might be operating off attribute names provided to the template or computed by another tag. It's similar to `|getitem:...` but uses a `getattr(obj, key)` call instead of `obj[key]`.
233a4c66454d27649279d75f6935fde6d0328e44 Christian Hammond
djblets/util/templatetags/djblets_utils.py
djblets/util/tests/test_djblets_utils_tags.py
Loading...