Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#5 New ESCAPE=JS option in v2.6

closed-accepted
nobody
None
5
2004-06-18
2002-11-22
Craig Manley
No

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.

Discussion

  • Craig Manley
    Craig Manley
    2002-11-22

    HTML-Template-2.6_js.tar.gz

     
  • Sam Tregar
    Sam Tregar
    2004-06-17

    • status: open --> open-postponed
     
  • Sam Tregar
    Sam Tregar
    2004-06-17

    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.

     
  • Craig Manley
    Craig Manley
    2004-06-17

    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.

     
  • Craig Manley
    Craig Manley
    2004-06-17

    Patch of v2.7 to support escape=js option.

     
  • Sam Tregar
    Sam Tregar
    2004-06-17

    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.

     
  • Sam Tregar
    Sam Tregar
    2004-06-17

    • status: open-postponed --> open-accepted
     
  • Sam Tregar
    Sam Tregar
    2004-06-18

    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

     
  • Craig Manley
    Craig Manley
    2004-06-18

    diff -bu patch of v2.7 to support escape=js option.

     
  • Craig Manley
    Craig Manley
    2004-06-18

    diff -u Patch of v2.7 to support escape=js option.

     
  • Craig Manley
    Craig Manley
    2004-06-18

    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.

     
  • Sam Tregar
    Sam Tregar
    2004-06-18

    • status: open-accepted --> closed-accepted
     
  • Sam Tregar
    Sam Tregar
    2004-06-18

    Logged In: YES
    user_id=3538

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