Re: [Lift] Re: Filtering of script tags from ajax replies and executing the javascript
Jon, The joys of being a committer is that you can open a ticket for adding this feature (and others), add it, get it reviewed and get it into Lift. My general rules is that if a pattern is useful for builders of one or two production apps, they'll probably be useful for others. So, please don't break existing APIs without a thorough discussion, but adding and enhancing is cool by me. Thanks, David On Wed, Dec 2, 2009 at 12:57 PM, jon jonhoff...@gmail.com wrote: Comments below. On Dec 2, 2:00 pm, Marius marius.dan...@gmail.com wrote: Personally I have reservations about this. If you want to include templates in this manner why use script tags in those templates ? ... I have existing templates which load as static pages and want to convert to ajaxy style page transitions without changing too many things. Also, I'm using something similar to the LazyLoad, which harryh shared a few months ago, which looks like this: lift:LazyLoad div id=foo lift:SomeSnippet/ /div script type=text/javascript //![CDATA[ alert('loaded'); //do something with foo //]] /script /lift:LazyLoad I get your point though, perhaps these are esoteric use cases. Furthermore in some cases one may want Script tags preserved. And having multiple SetHtml is not something I'd like to see (but others could). Besides stripping nodes out is a pretty trivial task using pattern matching or Scala's RuleTransformer. I also explored creating a trait that can be mixed into JqSetHtml to achieve the same goal: http://gist.github.com/247557 But I think it's too brittle to be generally useful. Last but not least I would avoid using open_! in such contexts. Try using openOr for graceful degradation. Under most circumstances I wouldn't use open_!, but for the case of hard coded template paths, I want things to fail in as loud a way as possible if I were to rename or fatfinger a path and that somehow made it into production (I have a top level catch all for exceptions which shoots out notifications and displays a nice error message). I realize that it would be hard to quickly parse the error cause, so I'm using something like this instead: def findTemplate_!(path:List[String]) = findAnyTemplate(path) openOr (throw new Exception(Template not found: + path.mkString(/))) Br's, Marius On Dec 2, 8:40 pm, jon jonhoff...@gmail.com wrote: Hi, It would be cool if when I did something like this: SHtml.a(()= SetHtml(id, findAnyTemplate(List(foo)).open_!)) The script tags within the foo template were filtered out and the the contained JavaScript were executed. I created my own SetHtml to achieve that, but I'm wondering if this would be interesting enough to add to Lift in a more comprehensive way (so that it works for all JsCmds that render NodeSeqs)? Here's what I got so far:http://gist.github.com/247425 - Jon -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Re: Filtering of script tags from ajax replies and executing the javascript
I think the feature has merits. I can see it either as an alternative to SetHtml (e.g., SetAndRun) or as a flag on SetHtml so existing code runs the same way. On Wed, Dec 2, 2009 at 11:00 AM, Marius marius.dan...@gmail.com wrote: Personally I have reservations about this. If you want to include templates in this manner why use script tags in those templates ? ... Furthermore in some cases one may want Script tags preserved. And having multiple SetHtml is not something I'd like to see (but others could). Besides stripping nodes out is a pretty trivial task using pattern matching or Scala's RuleTransformer. Last but not least I would avoid using open_! in such contexts. Try using openOr for graceful degradation. Br's, Marius On Dec 2, 8:40 pm, jon jonhoff...@gmail.com wrote: Hi, It would be cool if when I did something like this: SHtml.a(()= SetHtml(id, findAnyTemplate(List(foo)).open_!)) The script tags within the foo template were filtered out and the the contained JavaScript were executed. I created my own SetHtml to achieve that, but I'm wondering if this would be interesting enough to add to Lift in a more comprehensive way (so that it works for all JsCmds that render NodeSeqs)? Here's what I got so far:http://gist.github.com/247425 - Jon -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
[Lift] Re: Filtering of script tags from ajax replies and executing the javascript
Comments below. On Dec 2, 2:00 pm, Marius marius.dan...@gmail.com wrote: Personally I have reservations about this. If you want to include templates in this manner why use script tags in those templates ? ... I have existing templates which load as static pages and want to convert to ajaxy style page transitions without changing too many things. Also, I'm using something similar to the LazyLoad, which harryh shared a few months ago, which looks like this: lift:LazyLoad div id=foo lift:SomeSnippet/ /div script type=text/javascript //![CDATA[ alert('loaded'); //do something with foo //]] /script /lift:LazyLoad I get your point though, perhaps these are esoteric use cases. Furthermore in some cases one may want Script tags preserved. And having multiple SetHtml is not something I'd like to see (but others could). Besides stripping nodes out is a pretty trivial task using pattern matching or Scala's RuleTransformer. I also explored creating a trait that can be mixed into JqSetHtml to achieve the same goal: http://gist.github.com/247557 But I think it's too brittle to be generally useful. Last but not least I would avoid using open_! in such contexts. Try using openOr for graceful degradation. Under most circumstances I wouldn't use open_!, but for the case of hard coded template paths, I want things to fail in as loud a way as possible if I were to rename or fatfinger a path and that somehow made it into production (I have a top level catch all for exceptions which shoots out notifications and displays a nice error message). I realize that it would be hard to quickly parse the error cause, so I'm using something like this instead: def findTemplate_!(path:List[String]) = findAnyTemplate(path) openOr (throw new Exception(Template not found: + path.mkString(/))) Br's, Marius On Dec 2, 8:40 pm, jon jonhoff...@gmail.com wrote: Hi, It would be cool if when I did something like this: SHtml.a(()= SetHtml(id, findAnyTemplate(List(foo)).open_!)) The script tags within the foo template were filtered out and the the contained JavaScript were executed. I created my own SetHtml to achieve that, but I'm wondering if this would be interesting enough to add to Lift in a more comprehensive way (so that it works for all JsCmds that render NodeSeqs)? Here's what I got so far:http://gist.github.com/247425 - Jon -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.