From 41779291b8a4cd91e1fa5914dbebc96cd8cb7d20 Mon Sep 17 00:00:00 2001
From: Derek Willis <dwillis@gmail.com>
Date: Fri, 24 Sep 2010 17:24:31 -0400
Subject: [PATCH] clarified list-index lookup for dot notations
---
docs/ref/templates/api.txt | 3 ++-
docs/topics/templates.txt | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt
index 2ac4e65..207baf6 100644
a
|
b
|
in a variable name, it tries the following lookups, in this order:
|
120 | 120 | * List-index lookup. Example: ``foo[bar]`` |
121 | 121 | |
122 | 122 | The template system uses the first lookup type that works. It's short-circuit |
123 | | logic. |
| 123 | logic. Note that the final lookup type, the list-index, will not work if ``bar`` |
| 124 | is a string; it only works if ``bar`` is an integer. |
124 | 125 | |
125 | 126 | Here are a few examples:: |
126 | 127 | |
diff --git a/docs/topics/templates.txt b/docs/topics/templates.txt
index c3fdd2c..6bfbcdf 100644
a
|
b
|
Use a dot (``.``) to access attributes of a variable.
|
95 | 95 | * Dictionary lookup |
96 | 96 | * Attribute lookup |
97 | 97 | * Method call |
98 | | * List-index lookup |
99 | | |
| 98 | * List-index lookup (only works if the attribute is an integer) |
| 99 | |
100 | 100 | In the above example, ``{{ section.title }}`` will be replaced with the |
101 | 101 | ``title`` attribute of the ``section`` object. |
102 | 102 | |