Changeset 7276
- Timestamp:
- 03/17/08 19:14:41 (6 months ago)
- Files:
-
- django/trunk/AUTHORS (modified) (2 diffs)
- django/trunk/docs/templates.txt (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r7271 r7276 44 44 alang@bright-green.com 45 45 Marty Alchin <gulopine@gamemusic.org> 46 atlithorn <atlithorn@gmail.com> 46 47 Daniel Alves Barbosa de Oliveira Vaz <danielvaz@gmail.com> 47 48 AgarFu <heaven@croasanaso.sytes.net> … … 348 349 Makoto Tsuyuki <mtsuyuki@gmail.com> 349 350 tt@gurgle.no 351 David Tulig <david.tulig@gmail.com> 350 352 Amit Upadhyay 351 353 Geert Vanderkelen django/trunk/docs/templates.txt
r7122 r7276 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 ~~~~~~~~~~ … … 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 ~~~~ … … 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 ~~~~~~~ … … 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 ~~~~~~~~~~~~~~~ … … 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 ~~~~~~~~ … … 1269 1300 the argument. 1270 1301 1302 For example:: 1303 1304 {{ value|dictsort:"name" }} 1305 1306 If ``value`` is:: 1307 1308 [ 1309 {'name': 'zed', 'age': 19} 1310 {'name': 'amy', 'age': 22}, 1311 {'name': 'joe', 'age': 31}, 1312 ] 1313 1314 then the output would be:: 1315 1316 [ 1317 {'name': 'amy', 'age': 22}, 1318 {'name': 'joe', 'age': 31}, 1319 {'name': 'zed', 'age': 19} 1320 ] 1321 1271 1322 dictsortreversed 1272 1323 ~~~~~~~~~~~~~~~~ 1273 1324 1274 1325 Takes a list of dictionaries, returns that list sorted in reverse order by the 1275 key given in the argument. 1326 key given in the argument. This works exactly the same as the above filter, but 1327 the returned value will be in reverse order. 1276 1328 1277 1329 divisibleby … … 1279 1331 1280 1332 Returns true if the value is divisible by the argument. 1333 1334 For example:: 1335 1336 {{ value|divisibleby:3 }} 1337 1338 If ``value`` is ``21``, the output would be ``True``. 1281 1339 1282 1340 escape … … 1320 1378 ``'4.1 MB'``, ``'102 bytes'``, etc). 1321 1379 1380 For example:: 1381 1382 {{ value|filesizeformat }} 1383 1384 If ``value`` is 123456789, the output would be ``117.7 MB``. 1385 1322 1386 first 1323 1387 ~~~~~ … … 1325 1389 Returns the first item in a list. 1326 1390 1391 For example:: 1392 1393 {{ value|first }} 1394 1395 If ``value`` is ``['a', 'b', 'c']``, the output would be `a`. 1396 1327 1397 fix_ampersands 1328 1398 ~~~~~~~~~~~~~~ 1329 1399 1330 1400 Replaces ampersands with ``&`` entities. 1401 1402 For example:: 1403 1404 {{ value|fix_ampersands }} 1405 1406 If ``value`` is ``Tom & Jerry``, the output would be ``Tom & Jerry``. 1407 1408 **New in Django development version**: you probably don't need to use this 1409 filter since ampersands will be automatically escaped. See escape_ for more on 1410 how auto-escaping works. 1331 1411 1332 1412 floatformat … … 1389 1469 is less than 1). Otherwise, output is always an integer. 1390 1470 1471 For example:: 1472 1473 {{ value|get_digit:2 }} 1474 1475 If ``value`` is 123456789, the output would be ``8``. 1476 1391 1477 iriencode 1392 1478 ~~~~~~~~~ … … 1402 1488 ~~~~ 1403 1489 1404 Joins a list with a string, like Python's ``str.join(list)``. 1490 Joins a list with a string, like Python's ``str.join(list)`` 1491 1492 For example:: 1493 1494 {{ value|join:" // " }} 1495 1496 If ``value`` is ``['a', 'b', 'c']``, the output would be ``a // b // c``. 1405 1497 1406 1498 last … … 1411 1503 Returns the last item in a list. 1412 1504 1505 For example:: 1506 1507 {{ value|last }} 1508 1509 If ``value`` is ``['a', 'b', 'c', 'd']``, the output would be ``d``. 1510 1413 1511 length 1414 1512 ~~~~~~ … … 1416 1514 Returns the length of the value. Useful for lists. 1417 1515 1516 For example:: 1517 1518 {{ value|length }} 1519 1520 If ``value`` is ``['a', 'b', 'c', 'd']``, the output would be ``4``. 1521 1418 1522 length_is 1419 1523 ~~~~~~~~~ 1420 1524 1421 1525 Returns a boolean of whether the value's length is the argument. 1526 1527 For example:: 1528 1529 {{ value|length_is:4 }} 1530 1531 If ``value`` is ``['a', 'b', 'c', 'd']``, the output would be ``True``. 1422 1532 1423 1533 linebreaks … … 1428 1538 followed by a blank line becomes a paragraph break (``</p>``). 1429 1539 1540 For example:: 1541 1542 {{ value|linebreaks }} 1543 1544 If ``value`` is ``Joel\nis a slug``, the output would be ``<p>Joe<br>is a 1545 slug</p>``. 1546 1430 1547 linebreaksbr 1431 1548 ~~~~~~~~~~~~ … … 1451 1568 Converts a string into all lowercase. 1452 1569 1570 For example:: 1571 1572 {{ value|lower }} 1573 1574 If ``value`` is ``Joel Is a Slug``, the output would be ``joel is a slug``. 1575 1453 1576 make_list 1454 1577 ~~~~~~~~~ … … 1456 1579 Returns the value turned into a list. For an integer, it's a list of 1457 1580 digits. For a string, it's a list of characters. 1581 1582 For example:: 1583 1584 {{ value|make_list }} 1585 1586 If ``value`` is "Joe", the output would be ``[u'J', u'o', u'e']. If ``value`` is 1587 123, the output would be ``[1, 2, 3]``. 1458 1588 1459 1589 phone2numeric … … 1493 1623 ~~~~~~ 1494 1624 1495 A wrapper around pprint.pprint -- for debugging, really. 1625 A wrapper around `pprint.pprint`__ -- for debugging, really. 1626 1627 __ http://www.python.org/doc/2.5/lib/module-pprint.html 1496 1628 1497 1629 random … … 1500 1632 Returns a random item from the list. 1501 1633 1634 For example:: 1635 1636 {{ value|random }} 1637 1638 If ``value`` is ``['a', 'b', 'c', 'd']``, the output could be ``b``. 1639 1502 1640 removetags 1503 1641 ~~~~~~~~~~ 1504 1642 1505 1643 Removes a space separated list of [X]HTML tags from the output. 1644 1645 For example:: 1646 1647 {{ value|removetags:"b span"|safe }} 1648 1649 If ``value`` is ``<b>Joel</b> <button>is</button> a <span>slug</span>`` the 1650 output would be ``Joel <button>is</button> a slug``. 1506 1651 1507 1652 rjust … … 1536 1681 whitespace. 1537 1682 1683 For example:: 1684 1685 {{ value|slugify }} 1686 1687 If ``value`` is ``Joel is a slug``, the output would be ``joel-is-a-slug``. 1688 1538 1689 stringformat 1539 1690 ~~~~~~~~~~~~ … … 1546 1697 Python string formatting 1547 1698 1699 For example:: 1700 1701 {{ value|stringformat:"s" }} 1702 1703 If ``value`` is ``Joel is a slug``, the output would be ``Joel is a slug``. 1704 1548 1705 striptags 1549 1706 ~~~~~~~~~ 1550 1707 1551 1708 Strips all [X]HTML tags. 1709 1710 For example:: 1711 1712 {{ value|striptags }} 1713 1714 If ``value`` is ``<b>Joel</b> <button>is</button> a <span>slug</span>`` the 1715 output would be ``Joel is a slug``. 1552 1716 1553 1717 time … … 1558 1722 to the time of day, not the date (for obvious reasons). If you need to 1559 1723 format a date, use the `date`_ filter. 1724 1725 For example:: 1726 1727 {{ value|time:"H:i" }} 1728 1729 If ``value`` is ``datetime.datetime.now()``, the output would be formatted 1730 like ``01:23``. 1560 1731 1561 1732 timesince … … 1599 1770 1600 1771 **Argument:** Number of words to truncate after 1772 1773 For example:: 1774 1775 {{ value|truncatewords:2 }} 1776 1777 If ``value`` is ``Joel is a slug``, the output would be ``Joel is ...``. 1601 1778 1602 1779 truncatewords_html … … 1645 1822 Converts a string into all uppercase. 1646 1823 1824 For example:: 1825 1826 {{ value|upper }} 1827 1828 If ``value`` is ``Joel is a slug``, the output would be ``JOEL IS A SLUG``. 1829 1647 1830 urlencode 1648 1831 ~~~~~~~~~ … … 1658 1841 things won't work as expected. Apply this filter only to *plain* text. 1659 1842 1843 For example:: 1844 1845 {{ value|urlize }} 1846 1847 If ``value`` is ``Check out www.djangoproject.com``, the output would be 1848 ``Check out <a 1849 href="http://www.djangoproject.com">www.djangoproject.com</a>``. 1850 1660 1851 urlizetrunc 1661 1852 ~~~~~~~~~~~ … … 1668 1859 **Argument:** Length to truncate URLs to 1669 1860 1861 For example:: 1862 1863 {{ value|urlizetrunc:15 }} 1864 1865 If ``value`` is ``Check out www.djangoproject.com``, the output would be 1866 ``Check out <a 1867 href="http://www.djangoproject.com">www.djangopr...</a>``. 1868 1670 1869 wordcount 1671 1870 ~~~~~~~~~ … … 1679 1878 1680 1879 **Argument:** number of characters at which to wrap the text 1880 1881 For example:: 1882 1883 {{ value|wordwrap:5 }} 1884 1885 If ``value`` is ``Joel is a slug``, the output would be:: 1886 1887 Joel 1888 is a 1889 slug 1681 1890 1682 1891 yesno
