From 5a9e93e05423c176adfef714f804fe80e6fbb522 Mon Sep 17 00:00:00 2001 From: Jacek Bzdak Date: Tue, 20 Oct 2015 19:12:48 +0200 Subject: [PATCH] [1.9.x] Fixed #25574 -- Documented {{ dict.items }} shadowing in for template tag docs. Backport of 32cd7069711d2e02fcd20c005c59c175d542c62e from master --- docs/ref/templates/builtins.txt | 8 ++++++++ docs/ref/templates/language.txt | 2 ++ 2 files changed, 10 insertions(+) diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index d032d7b1cc1..4ab618866db 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -327,6 +327,14 @@ would display the keys and values of the dictionary:: {{ key }}: {{ value }} {% endfor %} +Keep in mind that for the dot operator, dictionary key lookup takes precedence +over method lookup. Therefore if the ``data`` dictionary contains a key named +``'items'``, ``data.items`` will return ``data['items']`` instead of +``data.items()``. Avoid adding keys that are named like dictionary methods if +you want to use those methods in a template (``items``, ``values``, ``keys``, +etc.). Read more about the lookup order of the dot operator in the +:ref:`documentation of template variables `. + The for loop sets a number of variables available within the loop: ========================== =============================================== diff --git a/docs/ref/templates/language.txt b/docs/ref/templates/language.txt index 4691a076891..0a50adfa191 100644 --- a/docs/ref/templates/language.txt +++ b/docs/ref/templates/language.txt @@ -74,6 +74,8 @@ explained later in this document. Oh, and one more thing: making humans edit XML is sadistic! +.. _template-variables: + Variables =========