  Filter functions should always return something. They shouldn't raise
  exceptions. They should fail silently. In case of error, they should return
  either the original input or an empty string -- whichever makes more sense.
  
  Here's an example filter definition::
  
      def cut(value, arg):
          "Removes all values of arg from the given string"
          return value.replace(arg, '')
  
 
</s> remove         "Removes all values of arg from the given string"
 </s> add         """Removes all values of arg from the given string""" </s> remove You can use ``register.filter()`` as a decorator instead::
 </s> add You can use ``register.filter()`` as a decorator instead:

.. code-block:: python </s> remove convert an object to its string value before being passed to your function::
 </s> add convert an object to its string value before being passed to your function:

.. code-block:: python </s> remove        For example, suppose you have a filter that adds the string ``xx`` to the
       end of any input. Since this introduces no dangerous HTML characters to
       the result (aside from any that were already present), you should mark
       your filter with ``is_safe``::
 </s> add        For example, suppose you have a filter that adds the string ``xx`` to
       the end of any input. Since this introduces no dangerous HTML characters
       to the result (aside from any that were already present), you should
       mark your filter with ``is_safe``:

       .. code-block:: python </s> remove For more examples of complex rendering, see the source code for ``{% if %}``,
``{% for %}``, ``{% ifequal %}`` and ``{% ifchanged %}``. They live in
 </s> add For more examples of complex rendering, see the source code for
:ttag:`{% if %}<if>`, :ttag:`{% for %}<for>`, :ttag:`{% ifequal %}<ifequal>`
or :ttag:`{% ifchanged %}<ifchanged>`. They live in
Here's an example filter definition:

.. code-block:: python
  Filter functions should always return something. They shouldn't raise
  exceptions. They should fail silently. In case of error, they should return
  either the original input or an empty string -- whichever makes more sense.
  
Here's an example filter definition:

.. code-block:: python
  
      def cut(value, arg):
          "Removes all values of arg from the given string"
          return value.replace(arg, '')
  
keep keep keep keep replace keep keep keep keep keep
 Brushed up the custom template tag 'howto' guide by moving the assignment_tag doc to a more appropriate place (i.e. under the "Setting a variable in the context" section), adding cross references, fixing a few minor inaccuracies and doing a little PEP8 cleanup.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16909 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
docs/howto/custom-template-tags.txt