Commits

George Notaras committed fc48d65

Added the ``meshterms`` filter

Comments (0)

Files changed (2)

src/primary_filters/templatetags/primary_filters_tags.py

 
 @register.filter
 @stringfilter
+def meshterms(value):
+    """Replaces commas with semicolon.
+    
+    Useful for converting a comma-delimited list of keywords to terms for
+    the Dublin Core dc.subject element.
+    
+    """
+    return utils.meshterms(value)
+
+
+@register.filter
+@stringfilter
 def dash2space(value):
     """Converts dashes to spaces."""
     return utils.dash2space(value)

src/primary_filters/utils.py

 from BeautifulSoup import BeautifulSoup, Comment
 
 
+def meshterms(value):
+    """Replaces commas with semicolon.
+    
+    Useful for converting a comma-delimited list of keywords to terms for
+    the Dublin Core dc.subject element.
+    
+    """
+    return value.replace(',', ';')
 
 def dash2space(value):
     """Converts dashes to spaces."""