Re: [htmltmpl] Patch to encode iso-8859-1 using HTML::Entities
Brought to you by:
samtregar
From: Alex K. <ka...@ra...> - 2004-10-19 09:48:38
|
Hi, Dave! Could you please elaborate a little. Why do want all the 8bit characters entities-encoded in the first place? It is perfectly normal for HTML to contain latin1 characters if there's a charset META or HTTP header (which you will need regardless of whether you encode entities or not). * Dave W. Smith <dw...@da...> [October 19 2004, 08:18]: > 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. -- Alex Kapranoff, #!/usr/bin/perl -w $SIG{__WARN__}=sub{print substr("@_",-43+ord$_,1)for '6.823O1US90:350:739OJ;0:*'=~m}.}g},$}='PJlshrk';reset$}+43; |