On Tue, 4 May 2004, Mark A. Fuller wrote: > Does %row have special meaning in HTML::Template? I saw it used in > another example. I don't know if I misunderstand something about > this example. (How would I use $row{__selected__} after I set it?)
It's just a common way to setup a loop: my @loop; foreach my $thing (@things) { my %row; $row{foo} = $thing->{bar}; push(@loop, \%row); } $template->param(things => [EMAIL PROTECTED]); So if I wanted to have <tmpl_var selected> set when $thing->{bar} was on I'd add this to the loop body: $row{selected} = "selected" if $thing->{bar}; > For example, what if H::T could recognize a special keyword (such as > TMPL_LOOP_SELECTED and TMPL_LOOP_CHECKED) inside the TMPL_LOOP and > automatically test an array of booleans with a reserved name (say, > @__selected__) who's index corresponds to H::T's internal row > counter. H::T could fill in the "selected" or "checked" value if all > the conditions are correct. How would you setup @__selected__? Would it really be easier than the single line of code shown above? > What I was getting at is that something seems to be missing in > TMPL_LOOP. There are two types of loops which are common, have a > known/standard requirement (testing for "selected" or "checked" on > every row), and the syntax for accomplishing this is always referred > to as "ugly." If it's so common, so standard, and so ugly, why can't > there be a way that H::T handles it behind the scenes? Actually, I find my standard way of accomplishing these things to be quite elegent. I actually like CGI.pm and I think it works very well with HTML::Template. Other people may choose to employ other solutions, but that doesn't motivate me to help them. > Doesn't this move the HTML out of the template? Sure, it's a trade-off. You gain some simplicity by setting up the <select> in your code. You lose some flexibility by not letting the HTML designer diddle a small chunk of HTML. I've found that it rarely causes problems since designers don't usually need to work on these tags. > If I have class attributes that may change depending on visitor > preferences, now I have to maintain them in two places (in the > template for everything except SELECT and RADIOBOX elements, and in > my Perl code for these two)? You're telling me you don't keep a list of your class attributes in your Perl code already? I don't believe you! -sam ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users