[Petal] Bug report: Dollar follwed by a name gets lost

Mark Holland mark at thinkfoo.com
Thu Aug 21 10:09:51 BST 2008


On 21/08/08 06:48, Thedi Gerber wrote:
> We are currently starting a new project and would like to use Petal. 
> While doing some exercises to get to know it, i tried to include a small 
> example perl script in a template. To my surprise, variable names in the 
> perl source were lost.
> 
> After some more tests, I came to this conclusion:
> 
> $variable                         IN THE template magically disappears
> $1000                             is ok
> $n                                is ok (single letter following a $)
> <span tal:content="xx">...</span> replaces the content always ok

Petal is interpolating $variable with parameters passed through 
->process(). If you were to pass through 'variable' as a argument you 
would see it printed. ($1000 and $n are not regarded as valid variable 
names).

E.g. if you were to change the following in your example:
   my %content_data = (nn => 'foo');
   my $task_result = $task->process( \%content_data );

you will see the output:

   "but nn dollars disappear <b>foo</b>!"

I've forgotten if there's a proper way to escape dollar characters in 
Petal, but one work around would be to use html entites, e.g.:

   This costs &#36;45

Cheers
~mark


More information about the Petal mailing list