[OpenAjaxIDE] HTML/JavaScript encoding for variable substitution
Kin Blas
jblas at adobe.com
Wed Aug 13 13:57:33 PDT 2008
Yeah the transformations were exactly what I was thinking. Just curious,
why are we prefixing as opposed to postfixing the transformation names?
I guess to my eyes, it would be easier to read the template code/markup
and see what properties were actually being used if they came after the
property names.
--== Kin ==--
________________________________
From: ide-bounces at openajax.org [mailto:ide-bounces at openajax.org] On
Behalf Of Jon Ferraiolo
Sent: Wednesday, August 13, 2008 11:09 AM
To: ide at openajax.org
Subject: [OpenAjaxIDE] HTML/JavaScript encoding for variable
substitution
Right now we have both property substitution using @@foo@@ syntax and
localization substitution using %%bar%%. Kin has asked if we can extend
the syntax to take into account the fact that a given substitution
string might appear within HTML content (which has its own syntax
quirks) and other times within JavaScript (with its own syntax quirks).
I promised to send an email with a proposal.
Here is what I propose - add two optional parenthetical prefixes,
(htmlchars) and (jschars) to variable references, where:
(htmlchars) transforms the substitution string to the following
replacements (aligns with PHP's htmlspecialchars()):
& with &
< with <
> with >
" with "
' with '
(jschars) transforms the substitution string to the following
replacements (aligns with PHP's addslashes()):
\ with \\
' with \'
" with \"
To illustrate (htmlchars), suppose your have:
<content>@@(htmlchars)remark@@</content>
and the user entered the following for the remark property: << I'm in
love! >>
then the resulting content would be: << I'm in love! >>
To illustrate (jschars), suppose you have:
<javascript>document.getElementById('textfield').value='@@(jschars)remar
k@@';</javascript>
then the resulting JavaScript would be:
document.getElementById('textfield').value='<< I\'m in love! >>';
I propose a variable reference can have either (htmlchars) or (jschars)
or neither, but not both.
Comments?
Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openajax.org/pipermail/ide/attachments/20080813/3ed1d1e0/attachment.html
More information about the IDE
mailing list