diff --git a/docs/templates.txt b/docs/templates.txt
index c351c95..4da1679 100644
a
|
b
|
add
|
1224 | 1224 | |
1225 | 1225 | Adds the arg to the value. |
1226 | 1226 | |
| 1227 | For example:: |
| 1228 | |
| 1229 | {{ value|add:2 }} |
| 1230 | |
| 1231 | If ``value`` is 4, then the output will be 6. |
| 1232 | |
1227 | 1233 | addslashes |
1228 | 1234 | ~~~~~~~~~~ |
1229 | 1235 | |
… |
… |
cut
|
1247 | 1253 | |
1248 | 1254 | Removes all values of arg from the given string. |
1249 | 1255 | |
| 1256 | For example:: |
| 1257 | |
| 1258 | {{ value|cut:" "}} |
| 1259 | |
| 1260 | If ``value`` is "String with spaces", the output will be ``Stringwithspaces``. |
| 1261 | |
1250 | 1262 | date |
1251 | 1263 | ~~~~ |
1252 | 1264 | |
1253 | 1265 | Formats a date according to the given format (same as the `now`_ tag). |
1254 | 1266 | |
| 1267 | For example:: |
| 1268 | |
| 1269 | {{ value|date:"D d M Y" }} |
| 1270 | |
| 1271 | If ``value`` is a datetime object (ie. datetime.datetime.now()), the output |
| 1272 | would be formatted like ``Wed 09 Jan 2008``. |
| 1273 | |
1255 | 1274 | default |
1256 | 1275 | ~~~~~~~ |
1257 | 1276 | |
1258 | 1277 | If value is unavailable, use given default. |
1259 | 1278 | |
| 1279 | For example:: |
| 1280 | |
| 1281 | {{ value|default:"nothing" }} |
| 1282 | |
| 1283 | If ``value`` is ``Undefined``, the output would be ``nothing``. |
| 1284 | |
1260 | 1285 | default_if_none |
1261 | 1286 | ~~~~~~~~~~~~~~~ |
1262 | 1287 | |
1263 | 1288 | If value is ``None``, use given default. |
1264 | 1289 | |
| 1290 | For example:: |
| 1291 | |
| 1292 | {{ value|default_if_none:"nothing" }} |
| 1293 | |
| 1294 | If ``value`` is ``None``, the output would be ``nothing``. |
| 1295 | |
1265 | 1296 | dictsort |
1266 | 1297 | ~~~~~~~~ |
1267 | 1298 | |
1268 | 1299 | Takes a list of dictionaries, returns that list sorted by the key given in |
1269 | 1300 | the argument. |
1270 | 1301 | |
| 1302 | For example:: |
| 1303 | |
| 1304 | {{ value|dictsort:"n" }} |
| 1305 | |
| 1306 | If ``value`` is ``[{'n': 'g', 'm': 0}, {'n': 'a', 'm': 2}, {'n': 'z', 'm': |
| 1307 | 8}]``, the output would be ``[{'n': 'a', 'm': 2}, {'n': 'g', 'm': 0}, {'n': 'z', 'm': |
| 1308 | 8}]``. |
| 1309 | |
1271 | 1310 | dictsortreversed |
1272 | 1311 | ~~~~~~~~~~~~~~~~ |
1273 | 1312 | |
1274 | 1313 | Takes a list of dictionaries, returns that list sorted in reverse order by the |
1275 | 1314 | key given in the argument. |
1276 | 1315 | |
| 1316 | For example:: |
| 1317 | |
| 1318 | {{ value|dictsortreversed:"n" }} |
| 1319 | |
| 1320 | If ``value`` is ``[{'n': 'g', 'm': 0}, {'n': 'a', 'm': 2}, {'n': 'z', 'm': |
| 1321 | 8}]``, the output would be ``[{'n': 'z', 'm': 8}, {'n': 'g', 'm': 0}, {'n': 'a', 'm': |
| 1322 | 2}]``. |
| 1323 | |
1277 | 1324 | divisibleby |
1278 | 1325 | ~~~~~~~~~~~ |
1279 | 1326 | |
1280 | 1327 | Returns true if the value is divisible by the argument. |
1281 | 1328 | |
| 1329 | For example:: |
| 1330 | |
| 1331 | {{ value|divisibleby:3 }} |
| 1332 | |
| 1333 | If ``value`` is 123456789, the output would be ``True``. |
| 1334 | |
1282 | 1335 | escape |
1283 | 1336 | ~~~~~~ |
1284 | 1337 | |
… |
… |
filesizeformat
|
1319 | 1372 | Format the value like a 'human-readable' file size (i.e. ``'13 KB'``, |
1320 | 1373 | ``'4.1 MB'``, ``'102 bytes'``, etc). |
1321 | 1374 | |
| 1375 | For example:: |
| 1376 | |
| 1377 | {{ value|filesizeformat }} |
| 1378 | |
| 1379 | If ``value`` is 123456789, the output would be ``117.7 MB``. |
| 1380 | |
1322 | 1381 | first |
1323 | 1382 | ~~~~~ |
1324 | 1383 | |
1325 | 1384 | Returns the first item in a list. |
1326 | 1385 | |
| 1386 | For example:: |
| 1387 | |
| 1388 | {{ value|first }} |
| 1389 | |
| 1390 | If ``value`` is ``['a', 'b', 'c']``, the output would be `a`. |
| 1391 | |
1327 | 1392 | fix_ampersands |
1328 | 1393 | ~~~~~~~~~~~~~~ |
1329 | 1394 | |
1330 | 1395 | Replaces ampersands with ``&`` entities. |
1331 | 1396 | |
| 1397 | For example:: |
| 1398 | |
| 1399 | {{ value|fix_ampersands }} |
| 1400 | |
| 1401 | If ``value`` is ``Tom & Jerry``, the output would be ``Tom & Jerry``. |
| 1402 | |
1332 | 1403 | floatformat |
1333 | 1404 | ~~~~~~~~~~~ |
1334 | 1405 | |
… |
… |
right-most digit, 2 is the second-right-most digit, etc. Returns the original
|
1388 | 1459 | value for invalid input (if input or argument is not an integer, or if argument |
1389 | 1460 | is less than 1). Otherwise, output is always an integer. |
1390 | 1461 | |
| 1462 | For example:: |
| 1463 | |
| 1464 | {{ value|get_digit:2 }} |
| 1465 | |
| 1466 | If ``value`` is 123456789, the output would be ``8``. |
| 1467 | |
1391 | 1468 | iriencode |
1392 | 1469 | ~~~~~~~~~ |
1393 | 1470 | |
… |
… |
join
|
1403 | 1480 | |
1404 | 1481 | Joins a list with a string, like Python's ``str.join(list)``. |
1405 | 1482 | |
| 1483 | For example:: |
| 1484 | |
| 1485 | {{ value|join:" or " }} |
| 1486 | |
| 1487 | If ``value`` is ``['a', 'b', 'c', 'd']``, the output would be ``a or be or c |
| 1488 | or d``. |
| 1489 | |
1406 | 1490 | last |
1407 | 1491 | ~~~~ |
1408 | 1492 | |
1409 | 1493 | Returns the last item in a list. |
1410 | 1494 | |
| 1495 | For example:: |
| 1496 | |
| 1497 | {{ value|last }} |
| 1498 | |
| 1499 | If ``value`` is ``['a', 'b', 'c', 'd']``, the output would be ``d``. |
| 1500 | |
1411 | 1501 | length |
1412 | 1502 | ~~~~~~ |
1413 | 1503 | |
1414 | 1504 | Returns the length of the value. Useful for lists. |
1415 | 1505 | |
| 1506 | For example:: |
| 1507 | |
| 1508 | {{ value|length }} |
| 1509 | |
| 1510 | If ``value`` is ``['a', 'b', 'c', 'd']``, the output would be ``4``. |
| 1511 | |
1416 | 1512 | length_is |
1417 | 1513 | ~~~~~~~~~ |
1418 | 1514 | |
1419 | 1515 | Returns a boolean of whether the value's length is the argument. |
1420 | 1516 | |
| 1517 | For example:: |
| 1518 | |
| 1519 | {{ value|length_is:4 }} |
| 1520 | |
| 1521 | If ``value`` is ``['a', 'b', 'c', 'd']``, the output would be ``4``. |
| 1522 | |
1421 | 1523 | linebreaks |
1422 | 1524 | ~~~~~~~~~~ |
1423 | 1525 | |
… |
… |
Replaces line breaks in plain text with appropriate HTML; a single
|
1425 | 1527 | newline becomes an HTML line break (``<br />``) and a new line |
1426 | 1528 | followed by a blank line becomes a paragraph break (``</p>``). |
1427 | 1529 | |
| 1530 | For example:: |
| 1531 | |
| 1532 | {{ value|linebreaks }} |
| 1533 | |
| 1534 | If ``value`` is ``Joel\nis a slug``, the output would be ``<p>Joe<br>is a |
| 1535 | slug</p>``. |
| 1536 | |
1428 | 1537 | linebreaksbr |
1429 | 1538 | ~~~~~~~~~~~~ |
1430 | 1539 | |
… |
… |
lower
|
1448 | 1557 | |
1449 | 1558 | Converts a string into all lowercase. |
1450 | 1559 | |
| 1560 | For example:: |
| 1561 | |
| 1562 | {{ value|lower }} |
| 1563 | |
| 1564 | If ``value`` is ``Joel Is a Slug``, the output would be ``joel is a slug``. |
| 1565 | |
1451 | 1566 | make_list |
1452 | 1567 | ~~~~~~~~~ |
1453 | 1568 | |
1454 | 1569 | Returns the value turned into a list. For an integer, it's a list of |
1455 | 1570 | digits. For a string, it's a list of characters. |
1456 | 1571 | |
| 1572 | For example:: |
| 1573 | |
| 1574 | {{ value|make_list }} |
| 1575 | |
| 1576 | If ``value`` is 123456789, the output would be ``[u'1', u'2', u'3', u'4', |
| 1577 | u'5', u'6', u'7', u'8', u'9']`` |
| 1578 | If ``value`` is 123456789, the output would be ``[u'J', u'o', u'e', u'l', |
| 1579 | u'i', u's', u'a', u's', u'l', u'u', u'g']`` |
| 1580 | |
1457 | 1581 | phone2numeric |
1458 | 1582 | ~~~~~~~~~~~~~ |
1459 | 1583 | |
… |
… |
random
|
1497 | 1621 | |
1498 | 1622 | Returns a random item from the list. |
1499 | 1623 | |
| 1624 | For example:: |
| 1625 | |
| 1626 | {{ value|random }} |
| 1627 | |
| 1628 | If ``value`` is ``['a', 'b', 'c', 'd']``, the output could be ``b``. |
| 1629 | |
1500 | 1630 | removetags |
1501 | 1631 | ~~~~~~~~~~ |
1502 | 1632 | |
1503 | 1633 | Removes a space separated list of [X]HTML tags from the output. |
1504 | 1634 | |
| 1635 | For example:: |
| 1636 | |
| 1637 | {{ value|removetags:"b span"|safe }} |
| 1638 | |
| 1639 | If ``value`` is ``<b>Joel</b> <button>is</button> a <span>slug</span>`` the |
| 1640 | output would be ``Joel <button>is</button> a slug``. |
| 1641 | |
1505 | 1642 | rjust |
1506 | 1643 | ~~~~~ |
1507 | 1644 | |
… |
… |
Converts to lowercase, removes non-word characters (alphanumerics and
|
1533 | 1670 | underscores) and converts spaces to hyphens. Also strips leading and trailing |
1534 | 1671 | whitespace. |
1535 | 1672 | |
| 1673 | For example:: |
| 1674 | |
| 1675 | {{ value|slugify }} |
| 1676 | |
| 1677 | If ``value`` is ``Joel is a slug``, the output would be ``joel-is-a-slug``. |
| 1678 | |
1536 | 1679 | stringformat |
1537 | 1680 | ~~~~~~~~~~~~ |
1538 | 1681 | |
… |
… |
the leading "%" is dropped.
|
1543 | 1686 | See http://docs.python.org/lib/typesseq-strings.html for documentation of |
1544 | 1687 | Python string formatting |
1545 | 1688 | |
| 1689 | For example:: |
| 1690 | |
| 1691 | {{ value|stringformat:"s" }} |
| 1692 | |
| 1693 | If ``value`` is ``Joel is a slug``, the output would be ``Joel is a slug``. |
| 1694 | |
1546 | 1695 | striptags |
1547 | 1696 | ~~~~~~~~~ |
1548 | 1697 | |
1549 | 1698 | Strips all [X]HTML tags. |
1550 | 1699 | |
| 1700 | For example:: |
| 1701 | |
| 1702 | {{ value|striptags }} |
| 1703 | |
| 1704 | If ``value`` is ``<b>Joel</b> <button>is</button> a <span>slug</span>`` the |
| 1705 | output would be ``Joel is a slug``. |
| 1706 | |
1551 | 1707 | time |
1552 | 1708 | ~~~~ |
1553 | 1709 | |
… |
… |
The time filter will only accept parameters in the format string that relate
|
1556 | 1712 | to the time of day, not the date (for obvious reasons). If you need to |
1557 | 1713 | format a date, use the `date`_ filter. |
1558 | 1714 | |
| 1715 | For example:: |
| 1716 | |
| 1717 | {{ value|time:"H:i" }} |
| 1718 | |
| 1719 | If ``value`` is ``datetime.datetime.now()``, the output would be formatted |
| 1720 | like ``01:23``. |
| 1721 | |
1559 | 1722 | timesince |
1560 | 1723 | ~~~~~~~~~ |
1561 | 1724 | |
… |
… |
Truncates a string after a certain number of words.
|
1597 | 1760 | |
1598 | 1761 | **Argument:** Number of words to truncate after |
1599 | 1762 | |
| 1763 | For example:: |
| 1764 | |
| 1765 | {{ value|truncatewords:2 }} |
| 1766 | |
| 1767 | If ``value`` is ``Joel is a slug``, the output would be ``Joel is ...``. |
| 1768 | |
1600 | 1769 | truncatewords_html |
1601 | 1770 | ~~~~~~~~~~~~~~~~~~ |
1602 | 1771 | |
… |
… |
upper
|
1642 | 1811 | |
1643 | 1812 | Converts a string into all uppercase. |
1644 | 1813 | |
| 1814 | For example:: |
| 1815 | |
| 1816 | {{ value|upper }} |
| 1817 | |
| 1818 | If ``value`` is ``Joel is a slug``, the output would be ``JOEL IS A SLUG``. |
| 1819 | |
1645 | 1820 | urlencode |
1646 | 1821 | ~~~~~~~~~ |
1647 | 1822 | |
… |
… |
Converts URLs in plain text into clickable links.
|
1655 | 1830 | Note that if ``urlize`` is applied to text that already contains HTML markup, |
1656 | 1831 | things won't work as expected. Apply this filter only to *plain* text. |
1657 | 1832 | |
| 1833 | For example:: |
| 1834 | |
| 1835 | {{ value|urlize }} |
| 1836 | |
| 1837 | If ``value`` is ``Check out www.djangoproject.com``, the output would be |
| 1838 | ``Check out <a |
| 1839 | href="http://www.djangoproject.com">www.djangoproject.com</a>``. |
| 1840 | |
1658 | 1841 | urlizetrunc |
1659 | 1842 | ~~~~~~~~~~~ |
1660 | 1843 | |
… |
… |
As with urlize_, this filter should only be applied to *plain* text.
|
1665 | 1848 | |
1666 | 1849 | **Argument:** Length to truncate URLs to |
1667 | 1850 | |
| 1851 | For example:: |
| 1852 | |
| 1853 | {{ value|urlizetrunc:15 }} |
| 1854 | |
| 1855 | If ``value`` is ``Check out www.djangoproject.com``, the output would be |
| 1856 | ``Check out <a |
| 1857 | href="http://www.djangoproject.com">www.djangopr...</a>``. |
| 1858 | |
1668 | 1859 | wordcount |
1669 | 1860 | ~~~~~~~~~ |
1670 | 1861 | |
… |
… |
Wraps words at specified line length.
|
1677 | 1868 | |
1678 | 1869 | **Argument:** number of characters at which to wrap the text |
1679 | 1870 | |
| 1871 | For example:: |
| 1872 | |
| 1873 | {{ value|wordwrap:5 }} |
| 1874 | |
| 1875 | If ``value`` is ``Joel is a slug``, the output would be:: |
| 1876 | |
| 1877 | Joel |
| 1878 | is a |
| 1879 | slug |
| 1880 | |
1680 | 1881 | yesno |
1681 | 1882 | ~~~~~ |
1682 | 1883 | |