Categories > TBS next version >

[request] Escape sequences

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: RwD
Date: 2004-05-30
Time: 11:08

[request] Escape sequences

is it possible to add in a system so tbs will escape strings for you?

I am not sure how to best do it...
syst_standard_mail = good old testin' string;

template

'{var._syst_standard_mail}'

becomes

'good old testin\' string'

in the output

I thought of several ways to do it:
'{var._syst_standard_mail;escape=';echar=\}'
(Where \ could be default for echar)

or
'{var._syst_standard_mail;escape}'
looks if the tbs is included within a string (but this seems to me to be nearly impossible to implement correctly}



I am not sure how you look at this problem, because it could very well be my own PHP responsibility to do this right, and we do want to keep programming code out of the template, but then again, it is not really application logic or anything...
By: Skrol29
Date: 2004-05-31
Time: 22:17

Re: [request] Escape sequences

Hi,

TBS does escape string yet:
  htmlconv=esc
By: RwD
Date: 2004-05-31
Time: 22:28

Re: [request] Escape sequences

That isn't really the same is it?

PHP
$test = "lalala'djskj";

Template:
alert ('{var.test;htmlconv=esc}');

Result in Javascript:
alert ('lalala''djskj');

Where I would need this:
alert ('lalala\'djskj');

ps, I see you fixed the bug in this message as well :)
By: Skrol29
Date: 2004-05-31
Time: 22:38

Re: [request] Escape sequences

Ho yes, that's true.

This can be done with the new MergeField() feature which enables you to merge some tags with a user function.

I don't undestand why you need to protec string in the page with chars you whant?
By: RwD
Date: 2004-06-01
Time: 16:21

Re: [request] Escape sequences

well, because obviously Javascript does not like your escape character method.

I need the quotes to be escaped with a backslash, and I only need the single quote escaped....

This seems a nice solution next to you last answer:
'{var._syst_standard_mail;escape='&%;echar=\}'
escapes the ', & and % characters with a backslash (& and % are only to demonstrate what I mean)

But I don't know how easy and fast this would be....