Branko Vukelic committed 8fa73a3

Added quote and quote_plus filters and bumped version

Comments (0)

Files changed (3)

     {% url_params current_url page=2 %}
     {# this works for both ``/foo?page=1`` and just ``/foo`` #}
+Template filters
+URL tools also include filters for manipulating data that will be used as part
+of URLs. To use them, you need to load the ``urls`` library first::
+    {% load urls %}
+The ``quote`` filter quotes URL parameters. It accepts optional safe characters
+that can be used to prevent quoting of certain characters. This filter uses
+`urllib.quote`_ for quoting. Safe characters inlude only the slash ``/`` by
+default. ::
+    {{ value|quote:"~/" }}
+The ``quote_plus`` filter is similart ot the `quote`_ filter, except that it
+converts all spaces to ``+``. This filter also takes optional safe 
+characters. The filter uses `urllib.quote_plus`_ for quoting. ::
+    {{ value|quote_plus }}
 Reporting bugs
 .. _Django documentation on QueryDict:
 .. _issue tracker:
+.. _urllib.quote:
+.. _urllib.quote_plus:
     description='Django helpers for dealing with URLs in templates',
-    version='0.0.5',
+    version='0.0.6',
     packages=['url_tools', 'url_tools.templatetags'],
     author='Monwara LLC',


 from __future__ import absolute_import, unicode_literals
+import urllib
 from django import template
 from ..helper import UrlHelper
     return u.get_full_path()
+def quote_param(value, safe='/'):
+    return urllib.quote(value, safe)
+def quote_param_plus(value, safe='/'):
+    return urllib.quote_plus(value, safe)