Fergal Daly | 1 Apr 15:44
Picon

Re: using $ in petal

I thought \$ was the one but if it's not working for you then I don't
have a suggestion beyond reading the source or using one of the other
perl TAL implementations which don't have $ syntax,

F

On 3/29/06, Jonathan Vanasco <jon@...> wrote:
>
> On Mar 29, 2006, at 3:55 AM, Fergal Daly wrote:
>
> > Petal is not strict TAL, it also includes some "features" like
> > $variable being the same as <span petal:replace="variable" />. So I
> > guess $aa is being replaced it's value (ie blank), my guess is that
> > something in the parser is wrong so it doesn't correctly recognise
> > single letter variables with $,
>
> Are there any known workarounds?  I can't seem to figure out any way
> to put the string $abc into a document
>
> \$var didn't work
> $$var didn't work
>
> $ isn't a standard html entity - its a 'special character' and not
> widely supported
> &dollar; is on some spec sheets, but i haven't found a browser that
> shows it
> &#036; is the equiv, but Petal seems to parse  it as a $ for
> interpolation ( so $a works, but $a[a]* doesn't )
>

(Continue reading)

Bruno Postle | 3 Apr 13:49

Re: using $ in petal

Jonathan Vanasco wrote:
> 
> Are there any known workarounds?  I can't seem to figure out any way  to 
> put the string $abc into a document

Not so elegant, but this should work:

   <span>$</span>abc

Escaping as \$ ought to be ok.  This would be a good thing to fix.

--

-- 
Bruno

Jonathan Vanasco | 4 Apr 19:39

nested expression workaround?

Does anyone know of a workaround for nested expressions?

I need to do the following (which is not petal-safe)

<span tal:repeat="object Objects">
	<span tal:content="object/object_id">id</span> - <span  
tal:content="object/object_name">name</span>
	<hr/>
	<span tal:content="additional_info/${object/object_id}"/>
</span>

anyone know if there's a workaroudn for this sort of thing?

Corey | 6 Apr 02:03
Favicon

macro substitution?


Hello!

I'm new to petal - have a question regarding best-practices, specifically regarding
metal includes/macros.

In summary, I want to be able to dynamically utilize 'metal:use-macro', so that my
calling cgi can set a variable, which will be passed to a base/common petal template,
which will then use the intended macro, as defined/set in the aformentioned variable.

Say I have:

.../dir/foo.html
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">

<head>
  <title>Foo</title>
</head>

<body metal:define-macro="body">
   <p>FOO!</p>
</body>

</html>

and I also have a:

.../dir/bar.html
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">

(Continue reading)

Corey | 6 Apr 03:27
Favicon

Re: macro substitution?


The following works for me, but seems... not very elegant ...

.../index.html
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">

<head>
  <title>Foo or Bar?</title>
</head>

<body>

<span petal:condition="true: foo">
  <span metal:use-macro="dir/foo.html#body" petal:omit-tag=""></span>
</span>

<span petal:condition="true: bar">
  <span metal:use-macro="dir/bar.html#body" petal:omit-tag=""></span>
</span>

</body>

</html>

.../dir/foo.html
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">

<head>
  <title>Foo</title>
</head>
(Continue reading)

Corey | 20 Apr 02:52
Favicon

repeat through hash


Is there any particular technical reason why the 'repeat' syntax can't/won't 
loop through hashes, as though passed to, say, the perl 'keys' or 'values' 
function, or something similar to 'for ( %{ $hash } ) { return $_ }'?

It seems rather limiting to only be able to iterate/loop through arrays or
arrays of hashes - I'm constantly finding that I have to design my libraries' 
data-structures around Petal; for instance, using arrays of hashes 
rather than plain hashes which are often more natural and appropriate.

Thanks,

Corey

Peter Rabbitson | 20 Apr 03:34
Picon

Re: repeat through hash

On Wed, Apr 19, 2006 at 05:52:00PM -0700, Corey wrote:
> 
> Is there any particular technical reason why the 'repeat' syntax can't/won't 
> loop through hashes, as though passed to, say, the perl 'keys' or 'values' 
> function, or something similar to 'for ( %{ $hash } ) { return $_ }'?
> 
> It seems rather limiting to only be able to iterate/loop through arrays or
> arrays of hashes - I'm constantly finding that I have to design my libraries' 
> data-structures around Petal; for instance, using arrays of hashes 
> rather than plain hashes which are often more natural and appropriate.
> 
> Thanks,
> 
> Corey
> 

What you probably need is the each: function provided by Petal::Utils.

Cheers

Corey | 20 Apr 04:31
Favicon

Re: repeat through hash

On Wednesday 19 April 2006 18:34, Peter Rabbitson wrote:
> On Wed, Apr 19, 2006 at 05:52:00PM -0700, Corey wrote:
> > Is there any particular technical reason why the 'repeat' syntax
> > can't/won't loop through hashes
<snip>
> What you probably need is the each: function provided by Petal::Utils.
>

Cool - just what the doctor ordered.

Thanks for the heads-up!

Corey | 20 Apr 07:28
Favicon

bug, or misunderstanding?


'Nother question!

Trying to iterate through one hash, then use its keys to get values from a
second hash.

$data = {

  'foo' =>  {
     'boat' => 'FOO_val_boat',
     'car'  => 'FOO_val_car',
  },

  'bar' =>  {
     'boat' => 'BAR_val_boat',
     'car'  => 'BAR_val_car',
  },

};

doesn't work:
<div petal:repeat="field each: data/foo"> <!-- iter through %{ $data->{foo} } -->
 <span petal:replace="data/bar/string:${data/foo}"> doesn't work! why not? </span>
</div>

works:
<div petal:repeat="field each: data/foo"> <!-- iter through %{ $data->{foo} } -->
 <span petal:define="var field/key"> $var equals "boat"</span>
 <span petal:replace="data/bar/string:${var}"> results in "BAR_val_boat" </span>
</div>
(Continue reading)

Corey | 20 Apr 07:35
Favicon

Re: bug, or misunderstanding?

On Wednesday 19 April 2006 22:28, Corey wrote:
<snip>
> I'd prefer the second version to the first, as the first version seems as though
> it should be unnecessary.
> 

Whoops:

I'd prefer the _first_ version to the _second_, as the _second_ version seems as
though it should be unnecessary.


Gmane