I vote for not changing the behavior but I would like, for next major version of PHPTAL, to break BC for escaping and remove the escaping of the dollar symbol:

${variable} -> variable
$${variable} -> $variable

Since TAL is heavily based on HTML/XML semantics I guess it makes more sense to escape using unicode point codes ($ for $) or custom entities. This would remove the need for backtracking when parsing interpolatable texts and remove possible ambiguities like the one described in the original mail.


On 10/27/09 11:53 AM, Kornel Lesiński wrote:
On 26-10-2009 at 23:10:45 Cameron Junge <cameron.ju...@finda.co.nz> wrote:

Eg. if I have a variable "amount" with the value 100, and I want to display is as $100 then I either have to do:
a) $ ${amount}; or
b) $<tal:block replace="amount" />; or
c) <tal:block replace="money: amount" />

$<x tal:replace="amount"/>


I think the last one isn't bad.

Various attempts at escaping have failed. "$$${amount}" comes out as "$${amount}"; "$${amount}" comes out as "${amount}"

I know that there are workarounds, but surely there must be some way to do what is relatively simple? or is this a bug?

Strictly speaking it's not a bug (it's deliberately coded that way). It's PHPTAL's simplistic approach to escaping of ${}:

1. '$${' is not interpreted as start of interpolated expression
2. '$${' is replaced with '${'

This gives:

${x} → value
$${x} → ${x}
$$${x} → $${x}
$$$${x} → $$${x}
$$$$${x} → $$$${x}

I could change it to:

${x} → value
$${x} → ${x}
$$${x} → $value
$$$${x} → $${x}
$$$$${x} → $$value
$$$$$${x} → $$${x}


• Pre-filters may need to deal with this to (un)escape text properly. With simpler rules you can just replace ${ with $${ to escape text. It's not so easy when you need to observe even/odd number of $s. • It breaks backwards compatibility (hopefully not many people have $$${x} in their templates)

Deal PHPTAL users, what's your opinion on this?

PHPTAL mailing list

Reply via email to