From: David Kaufman <david@gi...> - 2008-05-15 03:55:17
"Damien Clark" <d.clark@...> wrote:
> I would like to extend HTML::Template to allow the user to implement
> their own arbitrary escape functionality. [...] I am proposing the
> following changes to the HTML::Template API and template format:
> . Extend the syntax for <tmpl_var escape=(JS,HTML,URL,NONE,1,0)> to
> include user provided attribute values. Examples are probably more
> clear: <tmpl_var name=¹bla¹ escape=php> or in my case <tmpl_var
> name=¹bla2¹ escape=sql>.
> . The constructor to take the option ³escape² with the value being a
> hashref. The keys will be the escape names gives in the templates
> (e.g. php or sql) and the value a reference to a subroutine that is
> provided by the user to escape any special meanings to the syntax used
> in that context.
Very nice work, Damien!
+1 on the inclusion of this oft-requested feature!
I started to write the same patch a few years ago, thinking "this should be
easy," but stumbled when I realized just how easy it wasn't :-) Shortly
thereafter Sam accepted Craig Manley's patch that added escape=JS (to the
list of hard-coded escapes) and my immediate need for user-defined escaping
But there have still been many times that I wished could "bolt on" a new
escape=rot13 or something. We can filter the template with our own
arbitrary code, so it would be great to have the capability to also filter
PS: kudos too, for including tests!
From: Damien Clark <d.clark@cq...> - 2008-05-15 05:46:02
On 15/5/08 1:54 PM, "David Kaufman" <david@...> wrote:
> Very nice work, Damien!
> But there have still been many times that I wished could "bolt on" a new
> escape=rot13 or something. We can filter the template with our own
> arbitrary code, so it would be great to have the capability to also filter
> the data.
Thanks for your feedback Dave. I agree and have sent this patch to Sam a
couple of months ago, but I guess he has been too busy to respond. Sam, if
you are reading this and have a spare moment, I'd love to hear back from you
as to whether you are happy to incorporate this patch into the distribution.