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:"wysmedia.com"]); // stored as string ...
  4. render(x); // display the template instead render
  5. }
  6. }

URL: www.wysmedia.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.