# 
# Tools for templates.
# 

def ParseFilter(filter):
    """
    Convert "Value1|Value2|Value3|..." to [Value1,Value2,Value3, ...]
    Each value are striped and duplicates are removed.
    If the filter is already a list, the function do nothing.
    """
    if filter == None: return None
    if type(filter) is list: return filter
    filters = [filter.strip() for filter in filter.split('|')]
    filters = list(set(filters))
    return filters