Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion r12220 - django/trunk/docs/ref/template s
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
nore...@djangoproject.com  
View profile  
 More options Jan 12 2010, 6:36 pm
From: nore...@djangoproject.com
Date: Tue, 12 Jan 2010 17:36:19 -0600 (CST)
Local: Tues, Jan 12 2010 6:36 pm
Subject: [Changeset] r12220 - django/trunk/docs/ref/templates
Author: jezdez
Date: 2010-01-12 17:36:19 -0600 (Tue, 12 Jan 2010)
New Revision: 12220

Modified:
   django/trunk/docs/ref/templates/builtins.txt
Log:
Fixed #12496 - Added code examples to built-in filter documentation. Thanks, Arthur Koziel.

Modified: django/trunk/docs/ref/templates/builtins.txt
===================================================================
--- django/trunk/docs/ref/templates/builtins.txt        2010-01-12 23:35:54 UTC (rev 12219)
+++ django/trunk/docs/ref/templates/builtins.txt        2010-01-12 23:36:19 UTC (rev 12220)
@@ -1017,6 +1017,12 @@

 Adds slashes before quotes. Useful for escaping strings in CSV, for example.

+For example::
+
+    {{ value|addslashes }}
+
+If ``value`` is ``"I'm using Django"``, the output will be ``"I\'m using Django"``.
+
 .. templatefilter:: capfirst

 capfirst
@@ -1024,6 +1030,12 @@

 Capitalizes the first character of the value.

+For example::
+
+    {{ value|capfirst }}
+
+If ``value`` is ``"django"``, the output will be ``"Django"``.
+
 .. templatefilter:: center

 center
@@ -1031,6 +1043,12 @@

 Centers the value in a field of a given width.

+For example::
+
+    "{{ value|center:"15" }}"
+
+If ``value`` is ``"Django"``, the output will be ``"     Django    "``.
+
 .. templatefilter:: cut

 cut
@@ -1194,6 +1212,13 @@
 string safe for use in HTML, but does protect you from syntax errors when using
 templates to generate JavaScript/JSON.

+For example::
+
+    {{ value|escapejs }}
+
+If ``value`` is ``"testing\r\njavascript \'string" <b>escaping</b>"``,
+the output will be ``"testing\\x0D\\x0Ajavascript \\x27string\\x22 \\x3Cb\\x3Eescaping\\x3C/b\\x3E"``.
+
 .. templatefilter:: filesizeformat

 filesizeformat
@@ -1320,6 +1345,12 @@
 It's safe to use this filter on a string that has already gone through the
 ``urlencode`` filter.

+For example::
+
+    {{ value|iriencode }}
+
+If ``value`` is ``"?test=1&me=2"``, the output will be ``"?test=1&amp;me=2"``.
+
 .. templatefilter:: join

 join
@@ -1400,6 +1431,13 @@
 Converts all newlines in a piece of plain text to HTML line breaks
 (``<br />``).

+For example::
+
+    {{ value|linebreaksbr }}
+
+If ``value`` is ``Joel\nis a slug``, the output will be ``Joel<br />is a
+slug``.
+
 .. templatefilter:: linenumbers

 linenumbers
@@ -1407,6 +1445,22 @@

 Displays text with line numbers.

+For example::
+
+    {{ value|linenumbers }}
+
+If ``value`` is::
+
+    one
+    two
+    three
+
+the output will be::
+
+    1. one
+    2. two
+    3. three
+
 .. templatefilter:: ljust

 ljust
@@ -1416,6 +1470,12 @@

 **Argument:** field size

+For example::
+
+    "{{ value|ljust:"10" }}"
+
+If ``value`` is ``Django``, the output will be ``"Django    "``.
+
 .. templatefilter:: lower

 lower
@@ -1451,12 +1511,17 @@
 ~~~~~~~~~~~~~

 Converts a phone number (possibly containing letters) to its numerical
-equivalent. For example, ``'800-COLLECT'`` will be converted to
-``'800-2655328'``.
+equivalent.

 The input doesn't have to be a valid phone number. This will happily convert
 any string.

+For example::
+
+    {{ value|phone2numeric }}
+
+If ``value`` is ``800-COLLECT``, the output will be ``800-2655328``.
+
 .. templatefilter:: pluralize

 pluralize
@@ -1468,6 +1533,9 @@

     You have {{ num_messages }} message{{ num_messages|pluralize }}.

+If ``num_messages`` is ``1``, the output will be ``You have 1 message.``
+If ``num_messages`` is ``2``  the output will be ``You have 2 messages.``
+
 For words that require a suffix other than ``'s'``, you can provide an alternate
 suffix as a parameter to the filter.

@@ -1527,6 +1595,12 @@

 **Argument:** field size

+For example::
+
+    "{{ value|rjust:"10" }}"
+
+If ``value`` is ``Django``, the output will be ``"    Django"``.
+
 .. templatefilter:: safe

 safe
@@ -1565,6 +1639,8 @@

     {{ some_list|slice:":2" }}

+If ``some_list`` is ``['a', 'b', 'c']``, the output will be ``['a', 'b']``.
+
 .. templatefilter:: slugify

 slugify
@@ -1684,6 +1760,12 @@

 Converts a string into titlecase.

+For example::
+
+    {{ value|title }}
+
+If ``value`` is ``"my first post"``, the output will be ``"My First Post"``.
+
 .. templatefilter:: truncatewords

 truncatewords
@@ -1711,6 +1793,13 @@
 This is less efficient than ``truncatewords``, so should only be used when it
 is being passed HTML text.

+For example::
+
+    {{ value|truncatewords_html:2 }}
+
+If ``value`` is ``"<p>Joel is a slug</p>"``, the output will be
+``"<p>Joel is ...</p>"``.
+
 .. templatefilter:: unordered_list

 unordered_list
@@ -1761,6 +1850,13 @@

 Escapes a value for use in a URL.

+For example::
+
+    {{ value|urlencode }}
+
+If ``value`` is ``"http://www.example.org/foo?a=b&c=d"``, the output will be
+``"http%3A//www.example.org/foo%3Fa%3Db%26c%3Dd"``.
+
 .. templatefilter:: urlize

 urlize
@@ -1806,6 +1902,12 @@

 Returns the number of words.

+For example::
+
+    {{ value|wordcount }}
+
+If ``value`` is ``"Joel is a slug"``, the output will be ``4``.
+
 .. templatefilter:: wordwrap

 wordwrap


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.