On Thursday 27 June 2002 09:59 pm, Glenn Morgan wrote: > Hi > > Had a search through the archive but can't find what I'm looking for, so > here goes. > > I am using HTML::Template with PageKit and having a problem with > <tmpl_var> substitutions in javascript quoted strings. See below: > > <button onclick="javascript: js_str='<tmpl_var > name="tmpl_str">;"></button> > > If tmpl_str="It's a wonderful life" > > Then my resultant html is > > <button onclick="javascript: js_str='It's a wonderful life'";></button> > > This is obviously broken due to the unescaped single quote in It's. The > same would apply if the js string assignment was enclosed in double > quotes and I included doulble quotes in my tmp_str value. > > What I really need to do is: > > tmpl_str=It\'s a wonderful life > > and all would be well. > > 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? >
You need to filter the data looking for the character in the data stream. This is what I use to take care of that problem. $data =~ s|"|\\"|g; -- Douglas Kirkland Technical Support Department Rhyton Corporation [EMAIL PROTECTED] http://www.rhyton.com ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek We have stuff for geeks like you. http://thinkgeek.com/sf _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users
