Link to home
Start Free TrialLog in
Avatar of Xerc
Xerc

asked on

Simple conditional in Kid template used with CherryPy

I'm very new to CherryPy, but managed to get it running on FreeBSD.  Working great.  I started using the Kid template, as it is easier to implement than Cheetah, and I need only very basic functionality.  However, I've been unable to get any conditional (py:if) to work within the template.  Or more to the point, every conditional defaults to true apparently, or more likely the conditional is just not processed whatsoever.  

I've used the example from the following, but it doesn't work.....even if I may 5*6=2, it still shows the text.  http://kid-templating.org/language.html#conditionals-py-if

Any hints as to where I might be going wrong or if perhaps there is some configuration thing I need to do?
SOLUTION
Avatar of gelonida
gelonida
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Xerc
Xerc

ASKER

Sorry.  That was my typo in the question.  I double checked.  I did have comparison evaluator of == used.  

This is what I have in my template:   <p py:if="5 * 9 == 25">Math</p>  According to my understanding of Kid, "Math" should not be rendered / shown as 5 x 9 does not equal 25.  But it always shows up.  The Kid example from the page above is:  

<p py:if="5 * 5 == 25"> Python seems to be handling multiplication okay.</p>

I don't get how my syntax is different.

What's weird is that it appears Kid just isn't recognizing the py: portion, as when I look at the page source, py:if="5 * 9 == 25" appears within the <p> tag.  I know the Kid template otherwise works, as I'm passing it variables from CherryPy apps.  Very weird.
could you please lookwhat your web browser sees?
view the document as source.

What do you see?

DO you see:
<p py:if="5 * 9 == 25">Math</p>

or do you see?
<p>Math</p>
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
apologies Xerc

I should have read your reply in more detail. :-(


Does the example in the synopsis work?
(the one which should display the fruits)


Avatar of Xerc

ASKER

Ah.....I figured out the error.  In my one test template, I messed up the namespace which is associated with the py prefix.  I had xmlns:py="http://perl.org/kid/ns#".  To work it needs to be the correct ns of xmlns:py="http://purl.org/kid/ns#"  Very goof error on my part.  Perhaps a slip and wish to use Perl.  Heh.