We ran headlong into the need to add iso-8859-1 (Latin1) support to a large
webapp that used over a hundred templates. Rather than tracking down the
many places where we stuffed parameters, then modify them to use
HTML::Entities (and remove "ESCAPE=HTML"), I took the "simplest thing that
could possibly work" path, and added an 'encode_entities' option to new().
When true, it causes 7-bit unclean characters to be escaped via
HTML::Entities::encode_entities() when "ESCAPE=HTML" is used.

With the patch, getting most of the way to Latin1 support was a simple as
adding

  my $template = HTML::Template->new(
    filename => $template,
    global_vars => 1,
    cache => 1,
+   encode_entities => 1,
  );


The performance hit (for the encode_entities => 1 case) is < 1% for our app,
as measured via our unit test suite. 

The patch for HTML::Template 2.7, including doc changes and unit tests, is
http://www.davewsmith.com/code/HTML-Template-2_7-encode.diff

To maintain backward compatibility for people who expect single-quotes to be
escaped (e.g., for existing unit tests), single quotes are escaped either
way.

Dave



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to