Re: [PHPTAL] Escaping of dollar sign ($)
What about the html entity: #36; On 26/10/2009 23:10, Cameron Junge cameron.ju...@finda.co.nz wrote: Hi All, Not sure if this has been covered on this list before, my quick search couldn't find anything that seemed appropriate. If I wish to display a $ followed by a tal variable using the inline syntax (ie. ${variable}) then I have to either: a) put a space between the 2 $ signs; or b) use a tag to spit the variable out; or c) use a phptal_tales expression. 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 / 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? Cheers, Cameron. Notice This email and any attachments are strictly confidential and subject to copyright. They may contain privileged information. If you are not the intended recipient please delete the message and notify the sender. You should not read, copy, use, change, alter or disclose this email or its attachments without authorisation. The company and any related or associated companies do not accept any liability in connection with this email and any attachments including in connection with computer viruses, data corruption, delay, interruption, unauthorised access or unauthorised amendment. Any views expressed in this email and any attachments do not necessarily reflect the views of the company or the views of any of our related or associated companies. ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Escaping of dollar sign ($)
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
Re: [PHPTAL] Escaping of dollar sign ($)
I vote for not changing the current behaviour; I agree that if it's documented, it can be a little weird ;-) Personally I would choose to have a money formatter TALES construct, because I hate having to go through my templates again when I start adding another currency for instance. Best, Tjerk 2009/10/27 Kornel Lesiński kor...@aardvarkmedia.co.uk: On 27-10-2009 at 12:34:42 Iván Montes drsl...@pollinimini.net wrote: 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 (#36; for $) or custom entities. Unfortunately in XML it shouldn't matter whether you use literal $ or #36; (the difference is completely lost if you use W3C DOM for example). Theoretically PHPTAL should support #x24;#x7b;var#x7d; as well as ${var} :/ Custom entities require custom DOCTYPE/DTD, and that's just a can of worms. This would remove the need for backtracking when parsing interpolatable texts and remove possible ambiguities like the one described in the original mail. It can be unambiguous. It just has to be clearly defined and implemented in one way or another :) -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal -- -- Tjerk ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal