Grails plugin for sanchez.js Javascript templating framework.
This plugin allows simple inclusion of Sanchez templates in a Grails project, and re-use of grails partial templates on the client side.
In your Grails BuildConfig.groovy
, add the following to the plugins
section:
plugins {
...
runtime ':sanchez:{{current_version}}'
...
}
Next, you'll want to include the sanchez.js javascript file in your app.
Sanchez defines a resource module called sanchez
in SanchezResources.groovy
.
dependsOn 'jquery, sanchez'
<r:require modules="jquery,sanchez"/>
Inside a standard GSP file, you can include a gsp partial template as a sanchez template using the sanchez taglib:
<sanchez:render template="/section/tname" id="my_template" runtimeVars="data"/>
This will render /grails-app/views/section/_tname.gsp
as a sanchez template with id my_template
.
In your javascript:
sanchez.replaceWith("#oldContainer", "my_template", {data:"whatever"});