logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: repeat through hash: msg#00001

Subject: Re: repeat through hash

On Jun 7, 2006, at 8:29 AM, Josh Narins wrote:
1.a

I've always wanted petal to be perl'ier, and less TAL'ish.

<select name="perly">
 <option petal:repeat="a [sort [{BLOCK}] keys myHash]"
 petal:attributes="value="a" petal:content="myHash/a" />
</select>

i'd suggest using another rendering engine then. one of the biggest benefits / reasons for using TAL is that its a standard cross platform thing.

and you can just use functions to do what you want

tal:
<select name="perly">
 <option petal:repeat="a getHashrefSortedOnKeyValue 'myHash'"
 petal:attributes="value="a" petal:content="myHash/a" />
</select>

i think the code is something like:
        my %Personalized= (
                blah=> $var,
                getFunction=> \&function,
                getHashrefSortedOnKeyValue=> \&Path::To::function,
        );
        print $template->render( \%Personalized );

i'm a bit wrong on passing the data to a template to render - i acutally use an abstraction class to set it all up for me... all the info is in the main Petal spec the only thing i don't like about doing that, is that perl doesn't really implement iterators/generators like Python -- i think i mentioned this before... and in python when you yeild results from an object its cleaner/less annoying to do than with perl

Someone mentioned _other_ implementation of TAL in perl? Hrm.
search cpan... be warned though, they're all made because PETAL is too perlish and not strictly TAL enough in its performance.




<Prev in Thread] Current Thread [Next in Thread>