def string_to_dict(string):
 kwargs = {}
 if string:
  string = str(string)
  if (',' not in string):
   string += ','
  for arg in string.split(','):
   arg = arg.strip()
   if (arg == ''):
    continue
   (kw, val) = arg.split('=', 1)
   kwargs[kw] = val
 return kwargs

def string_to_dict ( string ) : kwargs = { } if string : string = str ( string ) if ( ',' not in string ) : string += ',' for arg in string . split ( ',' ) : arg = arg . strip ( ) if ( arg == '' ) : continue ( kw , val ) = arg . split ( '=' , 1 ) kwargs [ kw ] = val return kwargs
usage: {{ url|thumbnail:"width=10 .