[htmltmpl] JSEscape patch (was: (no subject))
Brought to you by:
samtregar
From: David K. <da...@gi...> - 2002-06-28 12:46:41
|
"Glenn Morgan" <Gl...@Mo...> wrote: > > I am using HTML::Template with PageKit and having a problem with > <tmpl_var> substitutions in javascript quoted strings...[snip] > > Unfortunately, > > 1) I am working with db data and am not aware of what chars data values > contain. > > 2) I am using the same data values in different places within the same > template and do not want escaped quotes in all cases. > > These two cases make it very messy to filter my datasets and escape > here, there and everywhere. > > Any ideas? Is there a simple solution or would a escape=quotes patch be > the way to go? i have had this problem, too. in addition to single and double quotes, Javascript literal strings cannot contain carriage returns, linefeeds, and (depending on the browser) tabs, either. and i also had output HTML that needed the value both ways, depending on where it was used in the document. in my case, i needed the value "JS-ESCAPED" to populate a data validation function, and HTML-ESCAPED elsewhere in the document for display. so i patched HTML::Template (v. 2.4) to add escape="JS" for that project. I never submitted the patch because 2.5 had already been released, and i kept meaning to make the patch for that latest version, but here, if it helps, is the patch i made for 2.4. maybe Sam will incorporate the patch in the next release, since we now share a common ex-boss :-) -dave |