← Back to team overview

team4alfanous team mailing list archive

[Branch ~team4alfanous/alfanous/alfanous-git] Rev 502: create a new django custom tag to replace a substring in a global string

 

------------------------------------------------------------
revno: 502
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Sun 2013-01-06 02:33:30 +0100
message:
  create a new django custom tag to replace a substring in a global string
modified:
  src/alfanous-django/wui/templatetags/custom_filters.py


--
lp:alfanous
https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git

Your team Alfanous team is subscribed to branch lp:alfanous.
To unsubscribe from this branch go to https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git/+edit-subscription
=== modified file 'src/alfanous-django/wui/templatetags/custom_filters.py'
--- src/alfanous-django/wui/templatetags/custom_filters.py	2013-01-02 10:51:41 +0000
+++ src/alfanous-django/wui/templatetags/custom_filters.py	2013-01-06 01:33:30 +0000
@@ -21,6 +21,13 @@
 	""" split a string counting on spaces """
 	return str.split()
 
+
+@register.simple_tag
+def string_replace( string, oldword, newword ):
+    """ replace all occurrences of oldword in string by newword    """
+    return string.replace( oldword, newword )
+
+
 @register.simple_tag
 def build_search_link( params, query, page, filter ):
     """ build a search link based on a new query 
@@ -42,6 +49,7 @@
     
     return build_params( new_params )
 
+
 def build_params(params):
 	""" Concatenate the params to build a url GET request """
 	get_request = ""