Hi Anthony,

    I think it is better to keep these if else (or for or while) statements 
in separate lines for clarity. Otherwise, it is causing trouble... For 
example. how would you interpret the statement below 
<a href="#"><i class="{{if ans=='A': }} {{response.write('icon-ok') if 
ans==correctans else response.write('icon-remove')}} {{ pass }}"></i></a>
This assumes the following logic :
  if ... :
          if ..... :
      else:
         ....

But i was thinking that it will implement the following logic:
   if ....:
          if......:
             .....
          else:
             ....

Most of the examples in the book are in separate lines... So it reduces the 
issues... But for compactness, i am trying to do it in one line... 
--Bhaskar


On Monday, December 24, 2012 10:14:35 PM UTC-6, Anthony wrote:
>
> It gets very difficult to apply the if.. else statements in more complex 
>> situations inside the view html code if the basics are not clearly 
>> understood. So i really want to understand the exact new syntax of using 
>> the if... else... in view html files before i start using them more and 
>> more.... Your help is greatly appreciated.
>
>
> It's exactly the same as in any Python code, except you have to close the 
> if/else with a {{pass}} statement (same with a for or while loop). Check 
> out http://web2py.com/books/default/chapter/29/05#The-views and 
> http://web2py.com/books/default/chapter/29/05#if...elif...else.
>
> Anthony 
>

-- 



Reply via email to