5

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 ?

alex
  • 479,566
  • 201
  • 878
  • 984
Denis
  • 7,127
  • 8
  • 37
  • 58

1 Answers1

11

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
tuomur
  • 6,888
  • 34
  • 37