Tracker: Patches

5 New ESCAPE=JS option in v2.6 - ID: 642485
Last Update: Comment added ( samtregar )

I've patched Template.pm version 2.6 so that it can now
escape Javascript strings too. You can do that by passing
the option ESCAPE=JS into a TMPL_VAR.

ESCAPE=HMTL and ESCAPE=URI are already supported,
but I often have to display Javascript alerts and create
dynamic DHTML/Javascript menus from data generated
by a perl script. I feel that the ESCAPE=JS option is the
only feature lacking from HTML::Template. With this
option, HTML::Template is capable of escaping the 3
most common string formats in web applications: URLs,
HTML, and Javascript.

For those interested in how this works you can test this
feature here:
http://www.varuvo.nl/cgi-bin/htmltemplatejs.cgi

I hope this feature wil be included in the next release.

An example cgi script with template is included in the
attached file.


Craig Manley ( cmanley ) - 2002-11-22 11:45:14 PST

5

Closed

Accepted

Nobody/Anonymous

None

None

Public


Comments ( 6 )

Date: 2004-06-18 10:33:52 PDT
Sender: samtregarProject Admin

Logged In: YES
user_id=3538

That worked great. This will be in 2.7. Thanks!


Date: 2004-06-18 10:23:22 PDT
Sender: cmanleyAccepting Donations

Logged In: YES
user_id=439666

Oke I've tried it again. The attachment
template_js_27_bu_patch.txt is with the diff -bu option. (-b
ignores all the removed extra trailing whitespace on each line
that my editor (UltraEdit) removed.
template_js_27_u_patch.txt is with the diff -u option. This
patch file is much larger.


Date: 2004-06-18 10:12:53 PDT
Sender: samtregarProject Admin

Logged In: YES
user_id=3538

This patch seems to be in an odd format that 'patch' doesn't
like. I'm getting an error stating: "patch: **** `>'
expected at line 6 of patch". Could you try regenerating
the patch using either cvs diff:

cvs diff -u Template.pm

Or just a normal diff -u:

diff -u Template.pm.old Template.pm

Thanks!
-sam




Date: 2004-06-17 12:38:35 PDT
Sender: samtregarProject Admin

Logged In: YES
user_id=3538

Awesome, thanks! And please accept my apologies for taking
nearly a year and a half to respond to this.


Date: 2004-06-17 12:35:56 PDT
Sender: cmanleyAccepting Donations

Logged In: YES
user_id=439666

That's because I only had a Windows PC at the time, so
patch files were something I couldn't make. Now I've got
Linux, and so I've made the patch file based on the lastest
CVS checkout. See attachment.




Date: 2004-06-17 11:41:13 PDT
Sender: samtregarProject Admin

Logged In: YES
user_id=3538

This isn't a patch, it's a whole new copy of the module. If
you can produce a patch against the latest CVS checkout I
would be inclined to accept it for the next release.


Attached Files ( 4 )

Filename Description Download
HTML-Template-2.6_js.tar.gz HTML-Template-2.6_js.tar.gz Download
htmltemplate27patch.txt Patch of v2.7 to support escape=js option. Download
template_js_27_bu_patch.txt diff -bu patch of v2.7 to support escape=js option. Download
template_js_27_u_patch.txt diff -u Patch of v2.7 to support escape=js option. Download

Changes ( 8 )

Field Old Value Date By
close_date - 2004-06-18 10:33:52 PDT samtregar
status_id Open 2004-06-18 10:33:52 PDT samtregar
File Added 91124: template_js_27_u_patch.txt 2004-06-18 10:21:09 PDT cmanley
File Added 91123: template_js_27_bu_patch.txt 2004-06-18 10:20:13 PDT cmanley
resolution_id Postponed 2004-06-17 12:38:35 PDT samtregar
File Added 91031: htmltemplate27patch.txt 2004-06-17 12:35:56 PDT cmanley
resolution_id None 2004-06-17 11:41:13 PDT samtregar
File Added 35961: HTML-Template-2.6_js.tar.gz 2002-11-22 11:45:14 PST cmanley