Grails: render template as String

/ Published in: Groovy
Save to your folder(s)

how to render GSP template as String ?
g:render is taglib in gsp ( ) but you can call it on your controller using g.render().

Copy this code and paste it in your HTML
  1. class MyController {
  2. def test = {
  3. def x = g.render(template:"/basecontroller/test",model:[name:""]); // stored as string ...
  4. render(x); // display the template instead render
  5. }
  6. }


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.