Hi,
I am rendering two GSP templates in a controller. The first template is rendered as follows:
String couponspage = (g.render(template: "availableCoupons", contentType:"text/html", model : [:]))?.toString()
I include the results of the first template in the model to the call to render the second template as follows:
render(template: "itemOffer", model: [merchantOffers: merchantOffers, asinnumbers: params.asinnumbers, linkshare : couponspage])
In the second GSP template, I use jQuery to update the contents of an element using the rendered template contained in the model as follows:
$("#elementid").html("${linkshare}")
Everything works if the rendered-template has all html elements on a single line. Unfortunately, my GSP template like many other html documents have tabs and newline characters to make the file readable by humans. g.render includes these control characters which seems to cause everything to break. A simple file that has Hello World contained in a paragraph element contained in a div element doesn't work.
"\n\t
Hello World
\n"(Sorry you can't see the paragraph and div elements in the above example.) The documentation suggest that what I am doing is straight forward and should work with no problem. I can't believe I have to strip the control characters from the rendered string or do I. Removing the call to jQuery and adding "${linkshare}" directly to the end of the second template also works. What gives?
Thanks