Author: gabrielhurley Date: 2010-12-28 16:53:28 -0600 (Tue, 28 Dec 2010) New Revision: 15086
Modified: django/trunk/docs/ref/templates/builtins.txt Log: Fixed #14912 -- Expanded documentation for the urlize template filter. Thanks to adamv for the draft patch. Modified: django/trunk/docs/ref/templates/builtins.txt =================================================================== --- django/trunk/docs/ref/templates/builtins.txt 2010-12-28 21:56:33 UTC (rev 15085) +++ django/trunk/docs/ref/templates/builtins.txt 2010-12-28 22:53:28 UTC (rev 15086) @@ -2072,39 +2072,55 @@ urlize ~~~~~~ -Converts URLs in plain text into clickable links. +Converts URLs in text into clickable links. -Note that if ``urlize`` is applied to text that already contains HTML markup, -things won't work as expected. Apply this filter only to *plain* text. +Works on links beginning with ``http://``, ``https://``, or ``www.`` and +ending with ``.org``, ``.net`` or ``.com``. Links can have trailing punctuation +(periods, commas, close-parens) and leading punctuation (opening parens) and +``urlize`` will still do the right thing. +Links generated by ``urlize`` have a ``rel="nofollow"`` attribute added +to them. + For example:: {{ value|urlize }} If ``value`` is ``"Check out www.djangoproject.com"``, the output will be -``"Check out <a -href="http://www.djangoproject.com">www.djangoproject.com</a>"``. +``"Check out <a href="http://www.djangoproject.com" +rel="nofollow">www.djangoproject.com</a>"``. +The ``urlize`` filter also takes an optional parameter ``autoescape``. If +``autoescape`` is ``True``, the link text and URLs will be escaped using +Django's built-in :tfilter:`escape` filter. The default value for +``autoescape`` is ``True``. + +.. note:: + + If ``urlize`` is applied to text that already contains HTML markup, + things won't work as expected. Apply this filter only to plain text. + .. templatefilter:: urlizetrunc urlizetrunc ~~~~~~~~~~~ -Converts URLs into clickable links, truncating URLs longer than the given -character limit. +Converts URLs into clickable links just like urlize_, but truncates URLs +longer than the given character limit. -As with urlize_, this filter should only be applied to *plain* text. +**Argument:** Number of characters that link text should be truncated to, +including the ellipsis that's added if truncation is necessary. -**Argument:** Length to truncate URLs to - For example:: {{ value|urlizetrunc:15 }} If ``value`` is ``"Check out www.djangoproject.com"``, the output would be -``'Check out <a -href="http://www.djangoproject.com">www.djangopr...</a>'``. +``'Check out <a href="http://www.djangoproject.com" +rel="nofollow">www.djangopr...</a>'``. +As with urlize_, this filter should only be applied to plain text. + .. templatefilter:: wordcount wordcount -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.