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

Re: [Cheetahtemplate-discuss] multiple filters

Expand Messages
  • Jeremy James
    ... It s probably ambigous as to how that would work anyway (which order should the filters be applied?) - the simple answer is create your own . -- import
    Message 1 of 3 , Jan 25, 2007
    • 0 Attachment
      ml wrote:
      > Is it possible to "stack" multiple filters?
      >
      > E.g. this doesn't work:
      > #filter WebSafe
      > #filter EncodeUnicode
      > $val
      > #endfilter
      > #endfilter

      It's probably ambigous as to how that would work anyway (which order
      should the filters be applied?) - the simple answer is 'create your own'.

      --
      import Filters from Cheetah

      class WebSafeUnicode(Filters.Filter):
      def filter(self,val,**kw):
      return Filters.WebSafe.filter(self,
      Filters.EncodeUnicode.filter(self,val,**kw),
      **kw)
      ---
      #filter WebSafeUnicode
      $var
      ---
      output = str(mytemplate(searchList=[foo], filter=WebSafeUnicode))
      ---

      You might even want to create a function that returns a 'stacked filter'
      class, using a specified list of filters.

      -jeremy

      -------------------------------------------------------------------------
      Take Surveys. Earn Cash. Influence the Future of IT
      Join SourceForge.net's Techsay panel and you'll get the chance to share your
      opinions on IT & business topics through brief surveys - and earn cash
      http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Mike Orr
      ... No. The inner filter will override the outer filter. Write your own combined filter, as Jeremy suggested. The WebSafe filter needs to be revamped to be
      Message 2 of 3 , Jan 25, 2007
      • 0 Attachment
        On 1/25/07, ml <ml@...> wrote:
        > Hi!
        >
        > Is it possible to "stack" multiple filters?
        >
        > E.g. this doesn't work:
        > #filter WebSafe
        > #filter EncodeUnicode
        > $val
        > #endfilter
        > #endfilter

        No. The inner filter will override the outer filter. Write your own
        combined filter, as Jeremy suggested.

        The WebSafe filter needs to be revamped to be Unicode safe. That's on my TODO.

        --
        Mike Orr <sluggoster@...>

        -------------------------------------------------------------------------
        Take Surveys. Earn Cash. Influence the Future of IT
        Join SourceForge.net's Techsay panel and you'll get the chance to share your
        opinions on IT & business topics through brief surveys - and earn cash
        http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      Your message has been successfully submitted and would be delivered to recipients shortly.