[Petal] repetitive string in attrributes - advice/tactics requested

Josh Narins josh at narins.net
Sun Aug 28 18:47:49 BST 2005


> i'm generating [a href=""]  on the fly a lot
> 
> the problem i'm having is that the bulk of the href is the same: ie
>     index.cgi?a=1&b=2&c=3&...z=1
>     index.cgi?a=1&b=2&c=3&...z=2
>     index.cgi?a=1&b=2&c=3&...z=3
> 
> my understanding of tal requires me to create the full href each time
> 
> is there any sort of magic where i would be able to not need to  
> specity the entire string?
> maybe something like:
>   baselink = index.cgi?a=1&b=2&c=3&..
>   href=baselink + attribute specific var

One is to generate the base string in the perl code that instantiates
and prints the petal template.


$template->process({ 
 base_href=> ('?' . join '&', map { $_ . '=' . $cgi{$_} } keys %cgi),
});


[a petal:attributes="href string:${base_href}&${unique_args}"]link[/a]


More information about the Petal mailing list