Ticket #13608: 13608.2.diff

File 13608.2.diff, 1.6 KB (added by Tim Graham, 12 years ago)
  • docs/ref/templates/api.txt

    diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt
    index c52194e..11ae8da 100644
    a b dot in a variable name, it tries the following lookups, in this order:  
    125125* Attribute lookup. Example: ``foo.bar``
    126126* List-index lookup. Example: ``foo[bar]``
    127127
     128Note that "bar" in a template expression like ``{{ foo.bar }}`` will be
     129intrepreted as a literal string and not using the value of the variable "bar",
     130if one exists in the template context.
     131
    128132The template system uses the first lookup type that works. It's short-circuit
    129133logic. Here are a few examples::
    130134
  • docs/topics/templates.txt

    diff --git a/docs/topics/templates.txt b/docs/topics/templates.txt
    index 2fa6643..1befc15 100644
    a b Use a dot (``.``) to access attributes of a variable.  
    102102    attempts to loop over a ``collections.defaultdict``::
    103103
    104104        {% for k, v in defaultdict.iteritems %}
    105             Do something with k and v here...
     105            Do something with k and v here...
    106106        {% endfor %}
    107107
    108108    Because dictionary lookup happens first, that behavior kicks in and provides
    If you use a variable that doesn't exist, the template system will insert  
    116116the value of the :setting:`TEMPLATE_STRING_IF_INVALID` setting, which is set
    117117to ``''`` (the empty string) by default.
    118118
     119Note that "bar" in a template expression like ``{{ foo.bar }}`` will be
     120intrepreted as a literal string and not using the value of the variable "bar",
     121if one exists in the template context.
     122
    119123Filters
    120124=======
    121125
Back to Top