I have a variable myvariable that I want to use in a Mako template. I want to be able to somehow check its type before doing anything with it. What is the syntax to check that sort of information? I know python has typeof and instanceof, but is there some equivalent in Mako or how would you do it?
Pseudocode below:
% if myvariable == 'list':
// Iterate Throuh the List
%for item in myvariable:
${myvariable[item]}
%endfor
%elif variabletype == 'int':
// ${myvariable}
%elif myvariable == 'dict':
// Do something here
You can use
isinstance()
:UPD. Here's the usage inside if/else/endif: