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

[Cheetahtemplate-discuss] testing for list membership with "in"

Expand Messages
  • Jeff Hinrichs - DM&T
    #set $groups = [ red , blue , green ] #if red in $groups # set $foo = found #else # set $foo = not found #end if $foo results in the error:
    Message 1 of 4 , May 6, 2007
    • 0 Attachment
      #set $groups = ['red','blue','green']
      #if 'red' in $groups
      # set $foo = "found"
      #else
      # set $foo = "not found"
      #end if

      $foo

      results in the error:

      NotFound: cannot find 'foo'

      So what idiom is used to test if a value exists in a list, with cheetah?

      thanks,

      --
      Jeff Hinrichs
      http://www.OmahaPython.org

      -------------------------------------------------------------------------
      This SF.net email is sponsored by DB2 Express
      Download DB2 Express C - the FREE version of DB2 express and take
      control of your XML. No limits. Just data. Click to get it now.
      http://sourceforge.net/powerbar/db2/
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Mike Orr
      ... The problem is the spaces before set . Cheetah thinks it s text rather than a directive. -- Mike Orr ... This SF.net email is
      Message 2 of 4 , May 6, 2007
      • 0 Attachment
        On 5/6/07, Jeff Hinrichs - DM&T <jeffh@...> wrote:
        > #set $groups = ['red','blue','green']
        > #if 'red' in $groups
        > # set $foo = "found"
        > #else
        > # set $foo = "not found"
        > #end if
        >
        > $foo
        >
        > results in the error:
        >
        > NotFound: cannot find 'foo'
        >
        > So what idiom is used to test if a value exists in a list, with cheetah?

        The problem is the spaces before 'set'. Cheetah thinks it's text
        rather than a directive.

        --
        Mike Orr <sluggoster@...>

        -------------------------------------------------------------------------
        This SF.net email is sponsored by DB2 Express
        Download DB2 Express C - the FREE version of DB2 express and take
        control of your XML. No limits. Just data. Click to get it now.
        http://sourceforge.net/powerbar/db2/
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • Jeff Hinrichs - DM&T
        ... Thanks - that was exactly my problem. Are there any standard idioms for handling checkboxes/option groups with cheetah? Thanks, Jeff ... This SF.net email
        Message 3 of 4 , May 7, 2007
        • 0 Attachment
          On 5/7/07, Mike Orr <sluggoster@...> wrote:
          > On 5/6/07, Jeff Hinrichs - DM&T <jeffh@...> wrote:
          > > #set $groups = ['red','blue','green']
          > > #if 'red' in $groups
          > > # set $foo = "found"
          > > #else
          > > # set $foo = "not found"
          > > #end if
          > >
          > > $foo
          > >
          > > results in the error:
          > >
          > > NotFound: cannot find 'foo'
          > >
          > > So what idiom is used to test if a value exists in a list, with cheetah?
          >
          > The problem is the spaces before 'set'. Cheetah thinks it's text
          > rather than a directive.
          >
          > --
          > Mike Orr <sluggoster@...>
          >

          Thanks - that was exactly my problem.

          Are there any standard idioms for handling checkboxes/option groups
          with cheetah?

          Thanks,

          Jeff

          -------------------------------------------------------------------------
          This SF.net email is sponsored by DB2 Express
          Download DB2 Express C - the FREE version of DB2 express and take
          control of your XML. No limits. Just data. Click to get it now.
          http://sourceforge.net/powerbar/db2/
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Mike Orr
          ... Not that I can think of. #def, #if, and one-line if may be useful. I use Quixote s form library, and am about to try ToscaWidgets. -- Mike Orr
          Message 4 of 4 , May 7, 2007
          • 0 Attachment
            On 5/7/07, Jeff Hinrichs - DM&T <jeffh@...> wrote:
            > On 5/7/07, Mike Orr <sluggoster@...> wrote:
            > > On 5/6/07, Jeff Hinrichs - DM&T <jeffh@...> wrote:
            > > > #set $groups = ['red','blue','green']
            > > > #if 'red' in $groups
            > > > # set $foo = "found"
            > > > #else
            > > > # set $foo = "not found"
            > > > #end if
            > > >
            > > > $foo
            > > >
            > > > results in the error:
            > > >
            > > > NotFound: cannot find 'foo'
            > > >
            > > > So what idiom is used to test if a value exists in a list, with cheetah?
            > >
            > > The problem is the spaces before 'set'. Cheetah thinks it's text
            > > rather than a directive.

            Not that I can think of. #def, #if, and one-line if may be useful. I
            use Quixote's form library, and am about to try ToscaWidgets.

            --
            Mike Orr <sluggoster@...>

            -------------------------------------------------------------------------
            This SF.net email is sponsored by DB2 Express
            Download DB2 Express C - the FREE version of DB2 express and take
            control of your XML. No limits. Just data. Click to get it now.
            http://sourceforge.net/powerbar/db2/
            _______________________________________________
            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.