views:

136

answers:

1
[% IF OrgType.id == Organization.org_type_id %]selected="selected"[% END %] 

Does not work even when they both evaluate to the same number.

[% IF OrgType.id == 3 %]selected="selected"[% END %] 

(i.e. hard-coding in a number for testing purposes) does work.

[% OrgType.id %] and [% Organization.org_type_id %] 

both print "3" on the page.

+7  A: 

The following works for me:

 my $tt = Template->new; 
 $tt->process( \"[% IF foo == bar %]blah[% END %]", { foo => 42, bar => 42 } );

That outputs 'blah'. So I suspect that your two variables don't contain what you think they do. Template Toolkit uses string equality for ==, so if you do:

 my $tt = Template->new; 
 $tt->process( \"[% IF foo == bar %]blah[% END %]", { foo => 42, bar => "42 " } );

It will break. You may need to massage the data a bit to get them to work right with string equality.

friedo