views:

88

answers:

3

The jQuery templates plug-in uses ${foo} syntax (example in jquery.tmpl doc):

$.tmpl( "<li>${Name}</li>", myData )

But Grails also uses it (example in Grails doc):

<body>
  Hello ${params.name}
</body>

So when I include $.tmpl( "<li>${Name}</li>", myData ) in my .gsp, Grails renders it as $.tmpl( "<li></li>", myData );.

Is there an easy way around this?

+2  A: 

I have only dabbled in Grails, but one option to get the literal output:

$.tmpl("<li><%='${Name}'%></li>", myData)
Nick Craver
@Nick Thanks, this works! I had been trying crazy stuff like `${"\$\{Name\}"}` to no avail.
Emmett
A: 

You may try using jquery.noConflict or jQuery itself:

jQuery.tmpl( "<li>${Name}</li>", myData )

or

var jqc = jQuery.noConflict();
jqc.tmpl( "<li>${Name}</li>", myData )
BaRoN
+1  A: 

use the alt syntax: {{= Name }}

http://api.jquery.com/template-tag-equal/

zack
Nice. This is fewer characters than Nick's solution, and it doesn't hose my syntax highlighting either!
Emmett