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"/>

${money: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}
etc.

I could change it to:

${x} → value
$${x} → ${x}
$$${x} → $value
$$$${x} → $${x}
$$$$${x} → $$value
$$$$$${x} → $$${x}
etc.


However:

• 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?

--
regards, Kornel

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to