Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with IF statement in mako template

I have mako template where i check conditions from a simple dict in for loop, like:

% for el in seq:
    % if el["attr"] == 1:
        ...
     elif:
        ....
     else:
        .....
     % endif

And if i want add another IF statement in this loop, like:

 %if el["attr1"] == 1:
       ....
 %endif

I have error: "SyntaxException: Keyword 'endif' doesn't match keyword 'for' in file" Its possible two or more IF statements in one FOR loop ?

like image 836
Denis Avatar asked Jul 08 '11 07:07

Denis


1 Answers

You're missing the %endfor and the % from elif and else statements:

%for el in seq:
    %if foo:
        pass
    %elif bar:
        pass
    %else:
        pass
    %endif
%endfor
like image 159
tuomur Avatar answered Sep 29 '22 23:09

tuomur