[Petal] Petal problem

Bruno Postle bruno at mkdoc.com
Fri Mar 11 17:39:10 GMT 2005


On Mon 07-Feb-2005 at 09:32 +0100, Christoph Thielecke wrote:
>
> If the "${1}" is in the text the parser fails.

Right, I've confirmed this.

Any Petal template with "${1}" in it fails because 
Petal::Hash::String thinks it looks like a variable but 
Petal::Hash::Var disagrees.

It is valid XML, but anything with '$' in it is going to be 
problematic because Petal uses it for variable substitution.

The following items all survive the Petal Parser untouched:

  <a>$</a>
  <b>$$</b>
  <c>$_</c>
  <f>$@</f>
  <g>$1</g>

..these are interpreted to nothing if they are undefined:

  <d>$foo</d>
  <e>${foo}</e>

..and these fail inelegantly:

  <h>${1}</h>
  <i>${1 bar}</i>
  <j>${1bar}</j>
  <k>${1_bar}</k>
  <l>${foo bar}</l>

The attached patch makes your particular problem go away, but I 
wonder if Petal should have a method of escaping '$' in a template.

Perhaps '$$foo' should be interpreted as the string '$foo' rather that 
a '$' followed by the variable '$foo'?

-- 
Bruno
-------------- next part --------------
Index: lib/Petal/Hash/String.pm
===================================================================
RCS file: /var/spool/cvs/Petal/lib/Petal/Hash/String.pm,v
retrieving revision 1.10
diff -r1.10 String.pm
15c15
< our $VARIABLE_RE_BRACKETS = qq |\\\$(?<!\\\\)\\{.*?(?<!\\\\)\\}|;
---
> our $VARIABLE_RE_BRACKETS = qq |\\\$(?<!\\\\)\\{[^0-9].*?(?<!\\\\)\\}|;


More information about the Petal mailing list