Loading ...
Sorry, an error occurred while loading the content.

[Cheetahtemplate-discuss] Filter isn't played for None value

Expand Messages
  • Thibaud Roussillat
    Hello, I have to apply filter to placeholders which can have None value. However, the filter isn t apply. For example : import Cheetah.Template from
    Message 1 of 1 , Nov 9, 2011
    • 0 Attachment
      Hello,

      I have to apply filter to placeholders which can have None value. However, the filter isn't apply.

      For example :

      import Cheetah.Template
      from Cheetah.Filters import Filter

      class MyFilter(Filter):

          def filter(self, val, **kw):
             
              return "tit"
             

      if __name__ == '__main__':
         
          print "test01"
         
          searchList=[{'myvar1': u'test'}, {'myvar2': None}]
         
          t = Cheetah.Template.Template('''
              1. -${getVar('myvar1', '456')}-
              2. -${getVar('myvar2', ''), maxlen=2}-
              3. -${getVar('myvar3', None), maxlen=2}-
              ''', searchList,
              filter=MyFilter
              )
          print t

      The output is as follow :

      1. -tit-
      2. --
      3. --

      Is there any way to apply filter to None value ?

      Thanks a lot.

      Thibaud

    Your message has been successfully submitted and would be delivered to recipients shortly.