"else:" statement is inline with "if" statement.
the code wrapped in {{ }} follows python syntax rules.
Alternatives below should be work (not tested):
A) using ternary operator
<a href="#"><i class="{{if ans=='A': }} {{response.write('icon-ok') if
ans==correctans else response.write('icon-remove')}} {{ pass }}"></i></a>
B) inline syntax with multiple {{ }}
<a href="#"><i class="{{if ans=='A': }} {{if ans==correctans:
response.write('icon-ok')}} {{else: response.write('icon-remove')}}
{{pass}} {{ pass }}"></i></a>
C) syntax not in line
<a href="#"><i class="{{if ans=='A': }}
{{if ans==correctans: response.write('icon-ok')
else: response.write('icon-remove')
pass }}
{{ pass }}"></i></a>
Il giorno martedì 25 dicembre 2012 00:40:01 UTC+1, Bhaskar Ramachandran ha
scritto:
>
> <a href="#"><i class="{{if ans=='A': }} {{if ans==correctans:
> response.write('icon-ok') else: response.write('icon-remove') pass }} {{
> pass }}"></i></a>
>
> I get a syntax error for the above code in view html file. I am trying to
> dynamically insert a tick icon or a cross icon depending on some variables.
> I tried different ways of expressing the if statements and none of them
> worked. I followed the book that says we should introduce a pass statement
> for every block (sometimes the block is obvious and in that case we don't
> need a pass statement).
>
> Please help catch the cause for syntax error.. Thank you
>
>
--