[Templates] passing undef as method arg inside a template

[prev] [thread] [next] [Date index for 2005/05/11]

From: Bart Simpson
Subject: [Templates] passing undef as method arg inside a template
Date: 02:03 on 11 May 2005
Is there a special way to pass undef to a method from
within a template? Does saying [% obj.method(undef) %]
somehow pass an empty string as an the arguemnt?

Why i ask is i'm getting different results from
"equivalent" code when its done in perl and when its
done inside the template.

Here's code in template and perl. in both cases, opt
is   a HTML::Element "option" object.
[%
    FOR opt IN element.content_list;
        opt.attr('selected', undef)
            IF opt.attr('selected');
    END;
    # Doesn't WORK. makes opt have selected="" 
%]

# in perl module method
     foreach my $opt ($cgi{$field}->content_list) {
       $opt->attr('selected', undef)
           if $opt->attr('selected');
     }
     # works , selected attribute is deleted entirely
     # as HTML::Element manual says should happen


thanks




		
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] passing undef as method arg inside a template
Bart Simpson 02:03 on 11 May 2005

Generated at 07:01 on 17 May 2005 by mariachi v0.52