Changeset 859
- Timestamp:
- 10/13/05 22:48:27 (3 years ago)
- Files:
-
- django/trunk/django/core/defaultfilters.py (modified) (1 diff)
- django/trunk/docs/templates.txt (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/defaultfilters.py
r666 r859 333 333 "If value is unavailable, use given default" 334 334 return value or arg 335 336 def default_if_none(value, arg): 337 "If value is None, use given default" 338 if value is None: 339 return arg 340 return value 335 341 336 342 def divisibleby(value, arg): django/trunk/docs/templates.txt
r736 r859 377 377 ``forloop.counter`` The current iteration of the loop (1-indexed) 378 378 ``forloop.counter0`` The current iteration of the loop (0-indexed) 379 ``forloop.revcounter`` The number of iterations from the end of the 379 ``forloop.revcounter`` The number of iterations from the end of the 380 380 loop (1-indexed) 381 ``forloop.revcounter0`` The number of iterations from the end of the 381 ``forloop.revcounter0`` The number of iterations from the end of the 382 382 loop (0-indexed) 383 383 ``forloop.first`` True if this is the first time through the loop … … 570 570 571 571 ``add`` 572 Adds the arg to the value 572 Adds the arg to the value. 573 573 574 574 ``addslashes`` 575 Adds slashes - useful for passing strings to JavaScript, for example.575 Adds slashes. Useful for passing strings to JavaScript, for example. 576 576 577 577 ``capfirst`` 578 Capitalizes the first character of the value 578 Capitalizes the first character of the value. 579 579 580 580 ``center`` 581 Centers the value in a field of a given width 581 Centers the value in a field of a given width. 582 582 583 583 ``cut`` 584 Removes all values of arg from the given string 584 Removes all values of arg from the given string. 585 585 586 586 ``date`` 587 Formats a date according to the given format (same as the ``now`` tag) 587 Formats a date according to the given format (same as the ``now`` tag). 588 588 589 589 ``default`` 590 If value is unavailable, use given default 590 If value is unavailable, use given default. 591 592 ``default_if_none`` 593 If value is ``None``, use given default. 591 594 592 595 ``dictsort`` … … 599 602 600 603 ``divisibleby`` 601 Returns true if the value is divisible by the argument 604 Returns true if the value is divisible by the argument. 602 605 603 606 ``escape`` 604 Escapes a string's HTML 607 Escapes a string's HTML. 605 608 606 609 ``filesizeformat`` … … 609 612 610 613 ``first`` 611 Returns the first item in a list 614 Returns the first item in a list. 612 615 613 616 ``fix_ampersands`` 614 Replaces ampersands with ``&`` entities 617 Replaces ampersands with ``&`` entities. 615 618 616 619 ``floatformat`` 617 620 Displays a floating point number as 34.2 (with one decimal places) - but 618 only if there's a point to be displayed 621 only if there's a point to be displayed. 619 622 620 623 ``get_digit`` … … 625 628 626 629 ``join`` 627 Joins a list with a string, like Python's ``str.join(list)`` 630 Joins a list with a string, like Python's ``str.join(list)``. 628 631 629 632 ``length`` 630 Returns the length of the value - useful for lists633 Returns the length of the value. Useful for lists. 631 634 632 635 ``length_is`` 633 Returns a boolean of whether the value's length is the argument 636 Returns a boolean of whether the value's length is the argument. 634 637 635 638 ``linebreaks`` 636 Converts newlines into <p> and <br />s639 Converts newlines into ``<p>`` and ``<br />``s. 637 640 638 641 ``linebreaksbr`` 639 Converts newlines into <br />s642 Converts newlines into ``<br />``s. 640 643 641 644 ``linenumbers`` 642 Displays text with line numbers 645 Displays text with line numbers. 643 646 644 647 ``ljust`` 645 Left-aligns the value in a field of a given width 648 Left-aligns the value in a field of a given width. 646 649 647 650 **Argument:** field size 648 651 649 652 ``lower`` 650 Converts a string into all lowercase 653 Converts a string into all lowercase. 651 654 652 655 ``make_list`` … … 655 658 656 659 ``phone2numeric`` 657 Takes a phone number and converts it in to its numerical equivalent 660 Takes a phone number and converts it in to its numerical equivalent. 658 661 659 662 ``pluralize`` 660 Returns 's' if the value is not 1, for '1 vote' vs. '2 votes' 663 Returns 's' if the value is not 1, for '1 vote' vs. '2 votes'. 661 664 662 665 ``pprint`` 663 A wrapper around pprint.pprint -- for debugging, really 666 A wrapper around pprint.pprint -- for debugging, really. 664 667 665 668 ``random`` 666 Returns a random item from the list 669 Returns a random item from the list. 667 670 668 671 ``removetags`` 669 Removes a space separated list of [X]HTML tags from the output 672 Removes a space separated list of [X]HTML tags from the output. 670 673 671 674 ``rjust`` 672 Right-aligns the value in a field of a given width 675 Right-aligns the value in a field of a given width. 673 676 674 677 **Argument:** field size … … 697 700 698 701 ``striptags`` 699 Strips all [X]HTML tags 702 Strips all [X]HTML tags. 700 703 701 704 ``time`` … … 703 706 704 707 ``timesince`` 705 Formats a date as the time since that date (i.e. "4 days, 6 hours") 708 Formats a date as the time since that date (i.e. "4 days, 6 hours"). 706 709 707 710 ``title`` 708 Converts a string into titlecase 711 Converts a string into titlecase. 709 712 710 713 ``truncatewords`` 711 Truncates a string after a certain number of words 714 Truncates a string after a certain number of words. 712 715 713 716 **Argument:** Number of words to truncate after … … 734 737 735 738 ``upper`` 736 Converts a string into all uppercase 739 Converts a string into all uppercase. 737 740 738 741 ``urlencode`` 739 Escapes a value for use in a URL 742 Escapes a value for use in a URL. 740 743 741 744 ``urlize`` 742 Converts URLs in plain text into clickable links 745 Converts URLs in plain text into clickable links. 743 746 744 747 ``urlizetrunc`` 745 Converts URLs into clickable links, truncating URLs to the given character limit 746 747 **Argument:** Length to truncate URLs to. 748 Converts URLs into clickable links, truncating URLs to the given character 749 limit. 750 751 **Argument:** Length to truncate URLs to 748 752 749 753 ``wordcount`` 750 Returns the number of words 754 Returns the number of words. 751 755 752 756 ``wordwrap`` 753 Wraps words at specified line length 754 755 **Argument:** number of words to wrap the text at.757 Wraps words at specified line length. 758 759 **Argument:** number of words at which to wrap the text 756 760 757 761 ``yesno``
