From d18579d21910d9e6d2a664cbaf9719785b1d0c7f Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 20 Sep 2014 16:55:54 +0200 Subject: [PATCH] Small fixes in templates topic guide. >>> from django.template.defaultfilters import register >>> len(register.filters) 57 --- docs/topics/templates.txt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/topics/templates.txt b/docs/topics/templates.txt index 40e1e9e2c7..7ec8c1ee37 100644 --- a/docs/topics/templates.txt +++ b/docs/topics/templates.txt @@ -74,7 +74,7 @@ explained later in this document. JavaScript and CSV. You can use the template language for any text-based format. - Oh, and one more thing: Making humans edit XML is sadistic! + Oh, and one more thing: making humans edit XML is sadistic! Variables ========= @@ -142,18 +142,16 @@ bio|truncatewords:30 }}``. This will display the first 30 words of the ``bio`` variable. Filter arguments that contain spaces must be quoted; for example, to join a -list with commas and spaced you'd use ``{{ list|join:", " }}``. +list with commas and spaces you'd use ``{{ list|join:", " }}``. -Django provides about thirty built-in template filters. You can read all about +Django provides about sixty built-in template filters. You can read all about them in the :ref:`built-in filter reference `. To give you a taste of what's available, here are some of the more commonly used template filters: :tfilter:`default` If a variable is false or empty, use given default. Otherwise, use the - value of the variable - - For example:: + value of the variable. For example:: {{ value|default:"nothing" }} @@ -161,8 +159,8 @@ used template filters: "``nothing``". :tfilter:`length` - Returns the length of the value. This works for both strings and lists; - for example:: + Returns the length of the value. This works for both strings and lists. + For example:: {{ value|length }} @@ -436,7 +434,7 @@ When generating HTML from templates, there's always a risk that a variable will include characters that affect the resulting HTML. For example, consider this template fragment:: - Hello, {{ name }}. + Hello, {{ name }} At first, this seems like a harmless way to display a user's name, but consider what would happen if the user entered their name as this::