[Chameleon-dev] template parser modification
Paul Spencer
pgs at magma.ca
Thu May 13 10:15:34 EDT 2004
All,
I've just committed a small change to the template parser variable
substitution code.
For those that don't know, it is possible to use substitution in your
application template using:
[#<filename>#] - inserts contents of <filename> at point of tag
[$var$] - inserts value of var from query string (url/form) into template
the [# #] processing happens before the [$ $] processing
Now for the change. The [$ $] processor previously provided no way to
decode the value before insertion, now we need to do this. To make it
most flexible, I have modified the code so that it decodes stuff by
default but if you add a ! it will not decode it (allowing embedding of
values into other urls, javascript functions etc).
So the new syntax is:
[$[!]<varname>$]
example url:
http://server.org/myapp/index.phtml?myval=This+is+my+val
Decoding:
<p>[$myval$]</p> - this will result in the following:
<p>This is my val</p>
No decoding:
<a href="http://another.org/cgi-bin/dothis?aval=[$!myval$]">Send myval
to cgi</a> - results in
<a href="http://another.org/cgi-bin/dothis?aval=$this+is+my+val">Send
myval to cgi</a>
Please note that the default behaviour has changed to perform the
decoding so if any of your existing templates rely on the non-decoding
behaviour, you will have to update them to include the !
I believe that in most cases the intention would be to get the decoded
value into the template, which is why I have made it the default. If
there are any disagreements to this, please let me know :)
Cheers,
Paul
More information about the Chameleon-dev
mailing list