[email protected] writes: >Seems like the method prepareForJavascript() would be pretty complex, >why not simply have javascript.vm generate the Javascript data? > >For example, here's a template that returns entries in JSON format >with a next/prev link so you can get the next batch of data.
Hi Dave Thanks for the suggestion. This won't fit the needs though. By having the layout in a single vm file I can use the content in two different ways. Both in normal text/html output and also through text/javascript. In the previous example layout.vm can be called both from a file that ends up delivering javascript (javascript.vm) and also from one that puts it all in normal html with <html> and <body> tags. Thus enhancing the re-usability. :) What prepareForJavascript needs to do is escape the relevant characters. Forinstance new-lines, hyphens and so forth. It's not too complex and something we already implemented and use through jsp tag-libs. Anyways, I ran into problems setting the content-type correctly both through a RequestMapper and a custom Model directly in the .vm. So perhaps the better solution would be to create two layout.vm's. One for JS output and one for HTML output. Cheers Søren Wiuff UNI-C
