NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Re: Template Toolkit: Alternating row colors (Score:2)
Using loop.count instead of loop.index makes that code a little simpler (loop.count is always loop.index + 1).
[% FOREACH object = domain.raObject %] <tr [% IF not (loop.count % 3) %]bgcolor="#EEEEEE"[% END %]>Also, I'd tend to do something like this with classes and stylesheets as it makes it easier to change in the future.
[% FOREACH object = domain.raObject %] <tr class="row_style_[% loop.count % 3 %]">You can then define three (or less) styles called "row_style_0", "row_style_1
Re: Template Toolkit: Alternating row colors (Score:2)
-Dom
Re: Template Toolkit: Alternating row colors (Score:2)
Re: Template Toolkit: Alternating row colors (Score:2)
JavaScript is a pleasant language, fairly small with a regular syntax and quite object oriented. It's got closures and objects and garbage collection and exceptions and all the things that you expect from a modern dynamic language. It's worth a second look if all you've ever done is bitch at badly written sites that use it...
-Dom
Re: Template Toolkit: Alternating row colors (Score:2)
I second that! JavaScript is a really nice language (especially if you keep IE 5 for Macintosh out of the game). What Do you guys think about this? [avantaxx.de]
The other good thing about JavaScript is: If you know it your an instant expert on ActionScript (Macromedia Flash programming language) :). At work, we seem to hav found at least a couple uses for Flash that are not annoying :)
Re: Template Toolkit: Alternating row colors (Score:2)
You must design your website so that it can function without Javascript (although possibly degraded).
Re: Template Toolkit: Alternating row colors (Score:2)
"Must" is such a heavy word. I usually reply "or what?"
Design tradeoffs are tradeoffs.
--
xoa
He already said or what (Score:1)
Re: Template Toolkit: Alternating row colors (Score:2)
But the point I was trying to make was that the language itself is worthy of closer inspection.
-Dom
Re: Template Toolkit: Alternating row colors (Score:2)
Re: Template Toolkit: Alternating row colors (Score:1)
Why would you want to include yet another js script when you can do the same thing in TT in a few lines of Perl? That is just crazy.
Then again I am retentive about controlling my code as much as possible. :-)
Re: Template Toolkit: Alternating row colors (Score:1)
Being new to Template Toolkit I had to google just to find that little piece of code.
Tie::Cycle (Score:2)
--
xoa
Re:Tie::Cycle (Score:2)
--
xoa
Re:Tie::Cycle (Score:2)
That isn't actually based on Tie::Cycle, it's a complete new reimplementation of the functionality.
Also it's not a properly written TT plugin. It doesn't inherit from Template::Plugin so you can't use it from a template like this:
If you replace Cycle.pm with the version that you'll find at http://dave.org.uk/template/ then it will work as expected.
I'll submit the patch to the author tonight.
Re:Tie::Cycle (Score:2)
Thanks for the patch. I hope Adam can crank it out soon. I wasn't too keen on having to pass in an iterator in the process() call.
--
xoa